473,396 Members | 1,871 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,396 software developers and data experts.

C# reparenting - focus problem

Hi,
I looked around for this specific problem but could not find any
answer - there's few things in VB but still nothing exactly like this
so I'd appreciate any help.
We're writing C# WinForm application that need to "silently" use
another app (called MapInfo) within itself - the intention is to use
this app (which is quite sophisticated mapping application) and add
some other extra functionality to it. We have a dll so we can run the
application using InteropServices.
We created a main form that is MDI container and has multiple other
forms as children. One of these children is MapInfo form which has got
nothing in itself. It only creates MapInfo executable which is again
another MDI container (C# just doesn't know about it obviously -
MapInfo is written in C++). Inside this MapInfo form we're using this
WIN API methods (after the MapInfo object has been created and we have
a pointer to it):

SetParent(MapInfo handle, parentForm handle);
SetWindowLong(miWin, GWL_STYLE, WS_VISIBLE) - to get rid of the border
etc.

I have certain simple mechanisms how to communicate with this object
but I'm facing one problem. Since my Main parent form is MDI container
- when I click on any child of this form (not the MapInfo ones) the
main parent form keeps focus (I have a menu, toolbar etc there).
However when I click on the MapInfo form (the one that encapsulates
the Interop object in itself) the main Form looses focus. As a result
of that - when the user does something in MapInfo application and
decides to click on one of our controls (toolbar or menu in the main
MDI container form) then he has to click twice. Ones to get the focus
back to the main form. And second time to actually activate the
control. The problem is that when users are within MapInfo - they're
within MapInfo form (the fake empty one that we've written in C#) but
the MapInfo form never gets focus.
I'm open to any ideas hot to solve this problem - I'm sure there must
be some solution to this problem
Thanks
Jan

Jun 13 '07 #1
3 4222

<ja********@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
Hi,
I looked around for this specific problem but could not find any
answer - there's few things in VB but still nothing exactly like this
so I'd appreciate any help.
We're writing C# WinForm application that need to "silently" use
another app (called MapInfo) within itself - the intention is to use
this app (which is quite sophisticated mapping application) and add
some other extra functionality to it. We have a dll so we can run the
application using InteropServices.
We created a main form that is MDI container and has multiple other
forms as children. One of these children is MapInfo form which has got
nothing in itself. It only creates MapInfo executable which is again
another MDI container (C# just doesn't know about it obviously -
MapInfo is written in C++). Inside this MapInfo form we're using this
WIN API methods (after the MapInfo object has been created and we have
a pointer to it):

SetParent(MapInfo handle, parentForm handle);
SetWindowLong(miWin, GWL_STYLE, WS_VISIBLE) - to get rid of the border
etc.

I have certain simple mechanisms how to communicate with this object
but I'm facing one problem. Since my Main parent form is MDI container
- when I click on any child of this form (not the MapInfo ones) the
main parent form keeps focus (I have a menu, toolbar etc there).
However when I click on the MapInfo form (the one that encapsulates
the Interop object in itself) the main Form looses focus. As a result
of that - when the user does something in MapInfo application and
decides to click on one of our controls (toolbar or menu in the main
MDI container form) then he has to click twice. Ones to get the focus
back to the main form. And second time to actually activate the
control. The problem is that when users are within MapInfo - they're
within MapInfo form (the fake empty one that we've written in C#) but
the MapInfo form never gets focus.
I'm open to any ideas hot to solve this problem - I'm sure there must
be some solution to this problem
Thanks
Jan
Put a button on the form and make the button set form.control.focus to a
control on the main from?

Jun 13 '07 #2
On Jun 13, 1:03 pm, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
<jan.lou...@gmail.comwrote in message

news:11**********************@i13g2000prf.googlegr oups.com...
Hi,
I looked around for this specific problem but could not find any
answer - there's few things in VB but still nothing exactly like this
so I'd appreciate any help.
We're writing C# WinForm application that need to "silently" use
another app (called MapInfo) within itself - the intention is to use
this app (which is quite sophisticated mapping application) and add
some other extra functionality to it. We have a dll so we can run the
application using InteropServices.
We created a main form that is MDI container and has multiple other
forms as children. One of these children is MapInfo form which has got
nothing in itself. It only creates MapInfo executable which is again
another MDI container (C# just doesn't know about it obviously -
MapInfo is written in C++). Inside this MapInfo form we're using this
WIN API methods (after the MapInfo object has been created and we have
a pointer to it):
SetParent(MapInfo handle, parentForm handle);
SetWindowLong(miWin, GWL_STYLE, WS_VISIBLE) - to get rid of the border
etc.
I have certain simple mechanisms how to communicate with this object
but I'm facing one problem. Since my Main parent form is MDI container
- when I click on any child of this form (not the MapInfo ones) the
main parent form keeps focus (I have a menu, toolbar etc there).
However when I click on the MapInfo form (the one that encapsulates
the Interop object in itself) the main Form looses focus. As a result
of that - when the user does something in MapInfo application and
decides to click on one of our controls (toolbar or menu in the main
MDI container form) then he has to click twice. Ones to get the focus
back to the main form. And second time to actually activate the
control. The problem is that when users are within MapInfo - they're
within MapInfo form (the fake empty one that we've written in C#) but
the MapInfo form never gets focus.
I'm open to any ideas hot to solve this problem - I'm sure there must
be some solution to this problem
Thanks
Jan

Put a button on the form and make the button set form.control.focus to a
control on the main from?
But I don't want the users to click on a button - I'm trying to get
standard MDI behaviour. When child (in my case the MapInfo application
is activated) - even the parent should be focused. By the way - I
tried it and even when I try to set focus to the top form - it return
false. That means that it couldn't get the focus.

Jun 13 '07 #3
On Wed, 13 Jun 2007 02:30:52 -0000, ja********@gmail.com wrote:
As a result
of that - when the user does something in MapInfo application and
decides to click on one of our controls (toolbar or menu in the main
MDI container form) then he has to click twice. Ones to get the focus
back to the main form. And second time to actually activate the
control. The problem is that when users are within MapInfo - they're
within MapInfo form (the fake empty one that we've written in C#) but
the MapInfo form never gets focus.
I'm open to any ideas hot to solve this problem - I'm sure there must
be some solution to this problem
I did play with the idea of embedding external forms within a .NET
application form a long time ago but quickly gave up on that as it was
obviously not something that was ever meant to work well. I did encounter
similar focus problems. One thing that you could try is track the mouse
movement (either by using some of the MouseXXX events of your form or
overriding the WndProc method and intercept the Windows Messages there) and
attempt to set the focus back to your own form whenever you detect that the
mouse has left the area covered by the MapInfo form. It might or might not
work. Even if it works, it's definitely going one ugly hack that might
confuse the user but then your whole application seems to be one ugly hack
to start with so I guess that you won't be too bothered by that.
Jun 13 '07 #4

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

Similar topics

3
by: Dai Ba Wong | last post by:
Hi: Currently I am having a problem with my webpage. My page consist of two frames, one consist of input text field and the other contains link for different pop-up windows. The problem...
2
by: Peter Wright | last post by:
Hi all. Hopefully this should demonstrate the problem I'm having: http://flooble.net/~pete/focus-problem-demo/ (I'm testing it in Mozilla only, but I'm not sure if it's actually a...
2
by: Jesper | last post by:
Last week I posted this for the first time. However, I didn't get any useable solution to my problem. I'm very keen on getting this problem solved, so please excuse me for trying again. I'll try to...
2
by: Elsa Luiz | last post by:
Hi everyone, I have this problem hope you could help me... I have an A.aspx page with a button, when I click the button I would like to open another window with containing B.aspx. The problem is...
1
by: avnrao | last post by:
Hi, I am facing a problem with control.focus (javascript). Here is the description of the issue. 1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on this, will redirect...
4
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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...
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,...

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.