I have a C++ CLR that contains windows forms on it, the project is a C++ CLR DLL library.
however, when I declare a variable for native HWND, without even using it. I get the following build error
1>C:dumpProjectMigrateNet8WinformDLLMyForm.h(19,3): error C2327: 'System::Windows::Forms::Control::HWND': is not a type name, static, or enumerator
here is the code
#pragma once
#include <wtypes.h>
namespace WinformDLL {
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
{
private:
HWND m_window;
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:
/// <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->SuspendLayout();
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(509, 211);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
}
#pragma endregion
};
}
What I have tried so far, is I already added the following framework references in the project file
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WPF" />
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
This is actualy taken from a project I am porting which is a winform C++ CLR and is now built as a DLL, but it has some lines that uses HWND on it. So i created a small code to easily debug the issue. but it seems like declaring HWND by itself even with the correct header file gives us the build error still.
How to resolve such build issue?