summaryrefslogtreecommitdiffstats
path: root/Tests/VSWindowsFormsResx
diff options
context:
space:
mode:
authorJohn Farrier <john.farrier@digitalinblue.com>2013-04-29 14:48:22 (GMT)
committerBrad King <brad.king@kitware.com>2013-05-16 17:06:44 (GMT)
commit79ec7868d0f08c9ff2e6fa6454b205132acecc24 (patch)
treea5526400e3ac907c10b42cfd28fbcd419a11a020 /Tests/VSWindowsFormsResx
parentc80594ba1274c3dc44c3f2efd70bd5c3d9066bf5 (diff)
downloadCMake-79ec7868d0f08c9ff2e6fa6454b205132acecc24.zip
CMake-79ec7868d0f08c9ff2e6fa6454b205132acecc24.tar.gz
CMake-79ec7868d0f08c9ff2e6fa6454b205132acecc24.tar.bz2
VS: Add Windows Forms Support
Add support to maintain designer functionality for Visual Studio C++ Windows Forms projects. Also add a test project showing how to use the CMakeLists.txt file and, when successfully configured, will allow use of the designer for the included form.
Diffstat (limited to 'Tests/VSWindowsFormsResx')
-rw-r--r--Tests/VSWindowsFormsResx/CMakeLists.txt44
-rw-r--r--Tests/VSWindowsFormsResx/WindowsFormsResx/Header.h0
-rw-r--r--Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.cpp1
-rw-r--r--Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h78
-rw-r--r--Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.resx61
-rw-r--r--Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp4
6 files changed, 188 insertions, 0 deletions
diff --git a/Tests/VSWindowsFormsResx/CMakeLists.txt b/Tests/VSWindowsFormsResx/CMakeLists.txt
new file mode 100644
index 0000000..a313ac2
--- /dev/null
+++ b/Tests/VSWindowsFormsResx/CMakeLists.txt
@@ -0,0 +1,44 @@
+#
+# Example CMakeLists.txt file to demonstrate how to make a designable Windows Forms project with CMake.
+#
+# Code modifications and example by John Farrier, john.farrier@helleboreconsulting.com
+#
+
+cmake_minimum_required(VERSION 2.8.10)
+
+# Project Name
+project(VSWindowsFormsResx CXX)
+
+include(CheckFunctionExists)
+include(CheckCXXSourceCompiles)
+include(CheckIncludeFile)
+
+# Note: The designable form is assumed to have a .h extension as is default in Visual Studio.
+# Node: The designable form is assumed to have a .resx file with the same name and path (save extension) as is default in Visual Studio
+
+set(TARGET_H
+ WindowsFormsResx/MyForm.h
+ WindowsFormsResx/Header.h
+ )
+
+set(TARGET_SRC
+ WindowsFormsResx/MyForm.cpp
+ WindowsFormsResx/Source.cpp
+ )
+
+set(TARGET_RESX
+ WindowsFormsResx/MyForm.resx
+ )
+
+set(TARGET_LIBRARIES ${SYSLIBS})
+add_executable(${PROJECT_NAME} ${TARGET_SRC} ${TARGET_H} ${TARGET_RESX})
+
+# Note: The property VS_GLOBAL_KEYWORD must be set.
+set_property(TARGET ${PROJECT_NAME} PROPERTY VS_GLOBAL_KEYWORD "ManagedCProj")
+
+# Note: The property VS_DOTNET_REFERENCES must be set.
+set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES "System" "System.Data" "System.Drawing" "System.Windows.Forms" "System.Xml")
+
+# Note: Modification of compiler flags is required for CLR compatibility now that we are using .resx files.
+string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
diff --git a/Tests/VSWindowsFormsResx/WindowsFormsResx/Header.h b/Tests/VSWindowsFormsResx/WindowsFormsResx/Header.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/VSWindowsFormsResx/WindowsFormsResx/Header.h
diff --git a/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.cpp b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.cpp
new file mode 100644
index 0000000..154e268
--- /dev/null
+++ b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.cpp
@@ -0,0 +1 @@
+#include "MyForm.h" \ No newline at end of file
diff --git a/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h
new file mode 100644
index 0000000..16222c5
--- /dev/null
+++ b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h
@@ -0,0 +1,78 @@
+#pragma once
+
+namespace Farrier {
+
+ using namespace System;
+ using namespace System::ComponentModel;
+ using namespace System::Collections;
+ using namespace System::Windows::Forms;
+ using namespace System::Data;
+ using namespace System::Drawing;
+
+ /// <summary>
+ /// Summary for MyForm
+ /// </summary>
+ public ref class MyForm : public System::Windows::Forms::Form
+ {
+ public:
+ MyForm(void)
+ {
+ InitializeComponent();
+ //
+ //TODO: Add the constructor code here
+ //
+ }
+
+ protected:
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ ~MyForm()
+ {
+ if (components)
+ {
+ delete components;
+ }
+ }
+ private: System::Windows::Forms::Button^ button1;
+ protected:
+
+ private:
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ System::ComponentModel::Container ^components;
+
+#pragma region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ void InitializeComponent(void)
+ {
+ this->button1 = (gcnew System::Windows::Forms::Button());
+ this->SuspendLayout();
+ //
+ // button1
+ //
+ this->button1->Location = System::Drawing::Point(13, 13);
+ this->button1->Name = L"button1";
+ this->button1->Size = System::Drawing::Size(75, 23);
+ this->button1->TabIndex = 0;
+ this->button1->Text = L"button1";
+ this->button1->UseVisualStyleBackColor = true;
+ //
+ // MyForm
+ //
+ this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
+ this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
+ this->ClientSize = System::Drawing::Size(284, 261);
+ this->Controls->Add(this->button1);
+ this->Name = L"MyForm";
+ this->Text = L"MyForm";
+ this->ResumeLayout(false);
+
+ }
+#pragma endregion
+ };
+}
diff --git a/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.resx b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.resx
new file mode 100644
index 0000000..e8ae276
--- /dev/null
+++ b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.resx
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file
diff --git a/Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp b/Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp
new file mode 100644
index 0000000..aee9e2e
--- /dev/null
+++ b/Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp
@@ -0,0 +1,4 @@
+int main(int argc, char **argv)
+{
+ return 0;
+}