473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Windows handles and windows forms

Hi

I want to specify the parent of a windows form to be a window handle I have
elsewhere in my project which is an unmanaged WIN32 handle. How can I do
this?

If I simple say myform->Parent=mainwnd (where mainwnd is a WIN32 handle) I
obviously get the error Cannort convert from HWND to
System::Windows::Forms::Control

Thanks

Nov 17 '05 #1
3 1821
I had a further thought that I could use the WIN32 API function SetParent as
in

SetParent(myform->Handle,mainwnd);

but I get error

Cannot convert from System::IntPtr to HWND

How can I do this

"Steve Marsden" <st***@conquest.ltd.uk> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Hi

I want to specify the parent of a windows form to be a window handle I
have
elsewhere in my project which is an unmanaged WIN32 handle. How can I do
this?

If I simple say myform->Parent=mainwnd (where mainwnd is a WIN32 handle) I
obviously get the error Cannort convert from HWND to
System::Windows::Forms::Control

Thanks

Nov 17 '05 #2
Try using :-

(HWND)myform->Handle.ToPointer()

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com /* MVP tips tricks and essays web site */
http://blog.voidnish.com /* My blog on C++/CLI, MFC, Whidbey, CLR... */
"Steve Marsden" <st***@conquest.ltd.uk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I had a further thought that I could use the WIN32 API function SetParent as in

SetParent(myform->Handle,mainwnd);

but I get error

Cannot convert from System::IntPtr to HWND

How can I do this

"Steve Marsden" <st***@conquest.ltd.uk> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Hi

I want to specify the parent of a windows form to be a window handle I
have
elsewhere in my project which is an unmanaged WIN32 handle. How can I do
this?

If I simple say myform->Parent=mainwnd (where mainwnd is a WIN32 handle) I obviously get the error Cannort convert from HWND to
System::Windows::Forms::Control

Thanks


Nov 17 '05 #3
Thanks Nish that did the trick.

I have further problem now that I have got past this.

In WIN32 programming if you create a child window on a top level window,
the child window cannot be activated when you click in it. All that happens
is the top level window is activated. This is the behaviour I want from my
Windows form child but this is not happening. The windows for can be
activated.

Is this beacuse I have just used SetParent on the Windows form to set its
parent to my main window or is it down to some property of of the Windows
form?

How can I stop a windows form child window from being activated

Thanks

Steve
"Nishant S" <ni**@nospam.asianetindia.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Try using :-

(HWND)myform->Handle.ToPointer()

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com /* MVP tips tricks and essays web site */
http://blog.voidnish.com /* My blog on C++/CLI, MFC, Whidbey, CLR... */
"Steve Marsden" <st***@conquest.ltd.uk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I had a further thought that I could use the WIN32 API function SetParent

as
in

SetParent(myform->Handle,mainwnd);

but I get error

Cannot convert from System::IntPtr to HWND

How can I do this

"Steve Marsden" <st***@conquest.ltd.uk> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
> Hi
>
> I want to specify the parent of a windows form to be a window handle I
> have
> elsewhere in my project which is an unmanaged WIN32 handle. How can I
> do
> this?
>
> If I simple say myform->Parent=mainwnd (where mainwnd is a WIN32
> handle) I > obviously get the error Cannort convert from HWND to
> System::Windows::Forms::Control
>
> Thanks
>
>
>



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.