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 7974129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:17:12+00:00 2026-06-04T08:17:12+00:00

Given the form System.Windows.Forms::Form Form1; and the window handle HWND hWnd; How can I

  • 0

Given the form

System.Windows.Forms::Form Form1;

and the window handle

HWND hWnd;

How can I set hWnd to the Handle property of Form1 that does truly exist as a public property that “Gets the window handle that the control is bound to. (Inherited from Control.)” according to the Microsoft documentation of System.Windows.Forms::Form? In the constructor of my Form Form1, I’ve tried

hWnd = this.Handle;

but the compiler complains:

error C2228: left of ‘.Handle’ must have class/struct/union type is ‘MyNamespace::Form1 ^const ‘ did you intend to use ‘->’ instead?

So I try

hWnd = this->Handle;

and just

hWnd = Handle; // Since I'm in the Form

and then the compiler says:

error C2440: ‘=’ : cannot convert from ‘System::IntPtr’ to ‘HWND’ No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

  • 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-06-04T08:17:13+00:00Added an answer on June 4, 2026 at 8:17 am

    I found a solution, and don’t care if it’s a kludge.

    hWnd = static_cast<HWND>(Handle.ToPointer());
    

    Works.

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

Sidebar

Related Questions

I have piece of Code in Form that works: public class Form1 : System.Windows.Forms.Form
I have a class which inherits System.Windows.Forms.Form. I need to make the form available
Is it possible to fetch a System.Windows.Forms.ContextMenu instance from a handle? By fetch I
I am trying to add a System.Windows.Forms.Control to a given forms control collection. I
I have a System.Windows.Form and a IntPtr acting as HWND. I want each of
Given some typical search form, I can't construct this form action when submitting a
Using Microsoft Spy++, I can see that the following windows that belong to a
I was given the following pseudo code in order to get the form that
I two forms, Form1, and a UserControl which hosts Form2. Within that UserControl on
I'm working on a windows forms application (.NET 4.0). My form contains a 'Fast

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.