473,672 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Odd Problem with SetParent

Hello to all,
I'm having something of a problem with the WinAPI call SetParent.
Here's the scenario.
I am trying to take an existing program, and run it within my own
window. I can make this
happen, the code looks like this:

/ Remove border and whatnot
long style = GetWindowLong(a ppWin, GWL_STYLE);
long new_style = WS_CHILD | WS_VISIBLE;
SetWindowLong(a ppWin, GWL_STYLE, new_style);

// Put it into this form
SetParent(appWi n, this.panel1.Han dle);
// Move the window to overlay it on this window
MoveWindow(appW in, 0, 0, this.Width, this.Height, true);
SendMessage((in t)m_appWin, WM_PAINT, 0, "");

Where appWin is the handle to the main window of the program I start
with Process.Start and
Handle is the handle of the control I want to "reparent" the window
within. It works fine, the
application is "relocated" within my window. However...

For Itunes (which is the program I'm trying to reparent), I can launch
it, reparent it, and have
it display itself properly. However, once I do, it no longer receives
any mouse clicks. It doesn't
even act as if the mouse is getting to that window. I've checked to
see if the mouse clicks are
going to MY window handle, but they are not.

Any ideas?

Thanks
Matt
Jun 27 '08 #1
7 7339
On Thu, 08 May 2008 11:30:39 -0700, Matt <ma********@spr ynet.comwrote:
[...]
For Itunes (which is the program I'm trying to reparent), I can launch
it, reparent it, and have
it display itself properly. However, once I do, it no longer receives
any mouse clicks. It doesn't
even act as if the mouse is getting to that window. I've checked to
see if the mouse clicks are
going to MY window handle, but they are not.

Any ideas?
Well, my first idea is that unless doing the exact same thing in an
unmanaged application works, but doesn't in your .NET application, this is
the wrong newsgroup for advice. I suspect that there's really nothing
about the question that relates to C# or .NET, and you'll get much better
advice posting to a newsgroup that is actually topical for the question.

Pete
Jun 27 '08 #2
On May 8, 12:40*pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Thu, 08 May 2008 11:30:39 -0700, Matt <matttel...@spr ynet.comwrote:
[...]
For Itunes (which is the program I'm trying to reparent), I can launch
it, reparent it, and have
it display itself properly. However, once I do, it no longer receives
any mouse clicks. It doesn't
even act as if the mouse is getting to that window. I've checked to
see if the mouse clicks are
going to MY window handle, but they are not.
Any ideas?

Well, my first idea is that unless doing the exact same thing in an *
unmanaged application works, but doesn't in your .NET application, this is*
the wrong newsgroup for advice. *I suspect that there's really nothing *
about the question that relates to C# or .NET, and you'll get much better *
advice posting to a newsgroup that is actually topical for the question.

Pete
Fair enough, I'm open to suggestions. What newsgroup would that be?

Matt
Jun 27 '08 #3
On Thu, 08 May 2008 11:46:37 -0700, Matt <ma********@spr ynet.comwrote:
Fair enough, I'm open to suggestions. What newsgroup would that be?
I can't say for sure. However, typing "win32" into my newsreader's
newsgroup search interface, I find:

comp.os.ms-windows.program mer.win32
microsoft.publi c.win32.program mer
microsoft.publi c.win32.program mer.ui

I would expect any one of those to be more appropriate, and there may be
other newsgroups that don't have "win32" in the name that are also more
appropriate. You might try using "windows", "programmer ", and/or
"programmin g" as other possible search terms.

Pete
Jun 27 '08 #4
On May 8, 2:30*pm, Matt <matttel...@spr ynet.comwrote:
Hello to all,
* *I'm having something of a problem with the WinAPI call SetParent.
Here's the scenario.
I am trying to take an existing program, and run it within my own
window. I can make this
happen, the code looks like this:

* * * * * */ Remove border and whatnot
* * * * * * long style = GetWindowLong(a ppWin, GWL_STYLE);
* * * * * * long new_style = WS_CHILD | WS_VISIBLE;
* * * * * * SetWindowLong(a ppWin, GWL_STYLE, new_style);

* * * * * * // Put it into this form
* * * * * * SetParent(appWi n, this.panel1.Han dle);

* * * * * * // Move the window to overlay it on this window
* * * * * * MoveWindow(appW in, 0, 0, this.Width, this.Height, true);
* * * * * * SendMessage((in t)m_appWin, WM_PAINT, 0, "");
Where you got that code from?
I dnot think that you can do what you want (I might be wrong though).
Each program will have their own message pump and I don't know how you
are going to transfer the emsage from one to the other.
Jun 27 '08 #5
On May 8, 3:31*pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac... @gmail.comwrote :
On May 8, 2:30*pm, Matt <matttel...@spr ynet.comwrote:


Hello to all,
* *I'm having something of a problem with the WinAPI call SetParent.
Here's the scenario.
I am trying to take an existing program, and run it within my own
window. I can make this
happen, the code looks like this:
* * * * * */ Remove border and whatnot
* * * * * * long style = GetWindowLong(a ppWin, GWL_STYLE);
* * * * * * long new_style = WS_CHILD | WS_VISIBLE;
* * * * * * SetWindowLong(a ppWin, GWL_STYLE, new_style);
* * * * * * // Put it into this form
* * * * * * SetParent(appWi n, this.panel1.Han dle);
* * * * * * // Move the window to overlay it on this window
* * * * * * MoveWindow(appW in, 0, 0, this.Width, this.Height, true);
* * * * * * SendMessage((in t)m_appWin, WM_PAINT, 0, "");

Where you got that code from?
I wrote it :)
I dnot think that you can do what you want (I might be wrong though).
Well, I've figured out a couple of ways to do most of this, I still
have some issues.
Each program will have their own message pump and I don't know how you
are going to transfer the emsage from one to the other.
The message pump really shouldn't matter. Clicks within the child
window should
be handled by it. At least I'd think so.

Matt

Jun 27 '08 #6
Hi Matt,
>>The message pump really shouldn't matter.
Of course it matters. Its message pump is not only on a different thread but
in a different process. We could speculate for example that the 'child'
thread attempts to route its messages to the outer frame window or some
other one of yours and then attempts to call its WindowProc. But this is in
a different process so different address space so the Window proc address is
garbage to the 'child'. So maybe it gets an exception and swallows the
message. Who knows really, but I'd be surprised if you could get this to
work.

Cheers
Doug Forster

Jun 27 '08 #7
On Thu, 08 May 2008 18:07:22 -0700, Doug Forster <no****@nowhere .com>
wrote:
Hi Matt,
>>The message pump really shouldn't matter.

Of course it matters. Its message pump is not only on a different thread
but in a different process. We could speculate for example that the
'child' thread attempts to route its messages to the outer frame window
or some other one of yours and then attempts to call its WindowProc. But
this is in a different process so different address space so the Window
proc address is garbage to the 'child'. So maybe it gets an exception
and swallows the message. Who knows really, but I'd be surprised if you
could get this to work.
Well, as the OP already said...for most applications it works fine, and
for iTunes it works fine at least at first.

Actually, it is not entirely uncommon for one process to host the window
of another process within itself. For example, OLE uses this for
out-of-proc servers. Windows will send the messages to the appropriate
window via the appropriate message queue (and thus the appropriate message
pump), assuming everything else has been configured correctly.

It's been so long since I've ever done anything like this, I can't
personally help the OP. And I really think that this newsgroup, where
most of the people are at the very least inexperienced with more
complicated unmanaged coding techniques, if not completely unfamiliar,
just isn't going to be a productive place to look for an answer.

It wouldn't surprise me if Willy or Ben, for example, know the answer to
the question but the fact is the OP is likely to have better luck in a
newsgroup where his question is actually on-topic.

Pete
Jun 27 '08 #8

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

Similar topics

0
8466
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1
1
545
by: Raghavendran Muraleetharan | last post by:
I have a requirement where I need to embed a VB 6 forms application into .Net forms application. Basically the new .Net application would act as a wrapper application and would control the embedded VB 6 application. I tried to start the VB 6 in a separate process from dot net app and acquired the handle of the handle to the main window of the process. Next I used to use Win32 API function SetParent to set the parent of the VB 6...
8
1460
by: twoeyedhuman1111 | last post by:
Okay, I have this sample code: class a; class b; class b { public: private:
0
1952
by: Jean Bon | last post by:
hello I have an application which manages a tree of objects. each object in the tree have a lot of references on other objects in the tree. in the application, I serialize a lot this tree using a binary formatter. there are a lot of classes in the application, I simplified the problem with those two classes A and B : class A : ISerializable
7
2625
by: Paul | last post by:
Hi. I need to launch a windows application and then send keyboard event to this process to run certain commands. I've created a COM+ appplication to spawn and talk to the application which works well however the launched application always shows the UI where-as I need this to be hidden, even calling the windowhidden on the process strart info does not work. Does this somehow need to spawned under a different account process ? ...
3
5745
by: miben | last post by:
I am creating a ListView through CreateWindowEx(). It works fine when I create it as a child window as so: hControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, WS_VISIBLE | WS_CHILD | LVS_REPORT, 300, 100, 100, 100, hWnd, NULL, NULL, NULL); However, I want to create the control with no parent, then add it to the parent form later. Something like this...
0
1602
by: clarionprogrammer | last post by:
Problem info: 1. My application runs in AppDomain1. 2. My plugin runs in AppDomain2. I am able to place the plugin form inside an application panel via the SetParent() API call. However, once SetParent() is used, the menu strip on the plugin ceases to function: It will no longer drop down the menu list once it is selected.
17
4470
Ganon11
by: Ganon11 | last post by:
Hey guys, OK, taking care of this beforehand; I AM a student in a university. This IS part of my homework, and (as a moderator), I'm doing my best to follow the posting guidelines I work so hard to enforce. Anyway, I'm trying to implement an areIsomorphic(TreeNode<T> first, TreeNode<T> second) function as defined below: Since this is a 'simple' problem, I've tried to do it using only TreeNodes rather than writing my own tree class...
0
1539
by: ramveers | last post by:
I ma creating a toolbar for IE. I am setting a parent of toolbar dynamically by using SetParent method of window API. My problem is that SetParent method does not set parent and return zero(IntPtr). By using last error code, its gives 1400 (Means Invalid Handle). I check that handle of toolbar and handle of new parent are valid, but previous parent of toolbar handle has been invalid. Now i want to assign new parent of toolbar but SetParent...
0
8408
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8832
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8611
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8685
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6240
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2067
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.