Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 522205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:19:49+00:00 2026-05-13T08:19:49+00:00

My managed c++ code fails to compile with the error message .\Window.cpp(11) : error

  • 0

My managed c++ code fails to compile with the error message

.\Window.cpp(11) : error C2440: 'initializing' : cannot convert from 'System::Windows::Forms::Form ^' to 'Enviroment::Window ^'
        No user-defined-conversion operator available, or
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
.\Window.cpp(11) : error C3754: delegate constructor: member function 'Enviroment::Window::_keydown' cannot be called on an instance of type 'System::Windows::Forms::Form ^'

Error   1   error C2440: 'initializing' : cannot convert from 'System::Windows::Forms::Form ^' to 'Enviroment::Window ^'    c:\Users\Thomas\Documents\Visual Studio 2008\Projects\Project_X\Project_X\Window.cpp    11
Error   2   error C3754: delegate constructor: member function 'Enviroment::Window::_keydown' cannot be called on an instance of type 'System::Windows::Forms::Form ^'  c:\Users\Thomas\Documents\Visual Studio 2008\Projects\Project_X\Project_X\Window.cpp    11

In window.h

ref class Window
    {
    public:
        Window();
        void _keydown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e);
    }

In window.cpp

Window::Window()
    {
        Form^ form = gcnew Form();
        form->KeyDown+= gcnew KeyEventHandler(form, &Window::_keydown);
}

and later

void Window::_keydown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e)
    {
        //stuff
    }

Help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:19:49+00:00Added an answer on May 13, 2026 at 8:19 am

    I think you mean to say:

    form->KeyDown+= gcnew KeyEventHandler(this, &Window::_keydown);
    

    In C++, a class function pointer is comprised of 2 things, the actual pointer (this part you got right) and a pointer to “this” to be passed to the function, which is of the type of the class holding the function. This is your Window, not Microsoft’s Form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I managed to get this code to compile with out error. But somehow it
From managed code, how do I load a managed type from another assembly at
I trying to write a simple function to call unmanaged code from managed code.
PostSharp 2.0 includes a CLR host and implements IHostAssemblyStore::ProvideAssembly. From managed code, I invoke:
Is there an easy way to set the volume from managed .net code?
Can .NET (managed code) read and write to CouchDB? I would like to build
Using the VS2010 debugger for managed code is it possible to trigger the finalizer
How to pause a program for a few milliseconds using C++ managed code? I
I'm currently in need of a purely managed code DirectX wrapper for .NET. While
According MSDN, FxCop is an application that analyzes managed code assemblies (code that targets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.