473,598 Members | 3,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(MapIn fo handle, parentForm handle);
SetWindowLong(m iWin, 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 4239

<ja********@gma il.comwrote in message
news:11******** **************@ i13g2000prf.goo glegroups.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(MapIn fo handle, parentForm handle);
SetWindowLong(m iWin, 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.fo cus to a
control on the main from?

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

news:11******** **************@ i13g2000prf.goo glegroups.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(MapIn fo handle, parentForm handle);
SetWindowLong(m iWin, 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.fo cus 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********@gmai l.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
2616
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 follows: 1. At the beginning, focus is placed on an input text field of the first frame (so there's a blinking cursor on such field). 2. Then users click on a link of the second frame (thus focus is set
2
3087
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 Mozilla-only problem) I'm capturing the focus and blur events for the document, updating a
2
2003
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 be a little more precise. I have an app running (minimized) and without showing itself on the task bar. It puts an icon in the task pane (next to the clock), and when I click this icon, a message handler is invoked and creates a new usercontrol...
2
1827
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 that the window B.aspx appears fine but the focus returns to the parent (A.aspx), I would like the focus in B.aspx window. When I click the button on A.aspx I execute the following code: private void btMyButton_Click(object sender,...
1
2229
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 page to Aspx2 which has a Datagrid. PageLoad of Aspx2 displays the DataGrid with existing data filled in and shows a new row (set of text boxes) in the Footer Item. Now, when I set the focus by accessing the first text box in the Footer
4
3941
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 textboxes and a checkbox. The behaviour I want from my app is as follows:- When the textbox (which is prior in tab order to the tab control) has been filled with a certain length of text by the user, the focus is
1
5132
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 the two steps, TextBox1.Text ="foo"; and TextBox2.Text = "bar";
11
7326
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 1.7.12 (linux kubuntu). It does work with konqueror. It seems to work with firefox on windows but not with IE (not completly sure though).
7
11911
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' and it steals the focus from the user's current application. How can I prevent the hidden WebBrowser from stealing focus? (And better yet can I even suppress that click?_
0
7991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8395
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8050
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
8265
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...
0
6719
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5438
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
3898
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
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2412
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.