Retaining Focus in owned Forms
-
Hi , I`ve just hit an interesting roadblock in my app & would really appreciate any help / feedback. The "bug" can be replicated easily. Basically, I have 2 forms running as 2 different processes , say Form X & Form Y. Their properties are : Form X : ShowinTaskbar = true , FixedToolWindow , Maximized. Form Y : Showintaskbar = false , Borderstyle.None , Normal We have methods on Form Y that can be invoked via Remoting to do Show(owner) , usually Form X ends up being the owner here. I`ve impleneted the IWin32Window interface and initialise it with my Form X`s handle (obtained via FindWindow) The issue is that Form Y can NEVER retain focus (say when u click on a text box in it) and focus always gets transferred to the owner Form X. I`m not really setting an Owner / Owned relationship between them formally, say , via AddOwnedForms in Form X or Form.Owner = FormX since i guess this doesnt work across processes. If we change the ShowInTaskbar property of Form X to false , or Form Y to true then there is no problem with the Focus. Can someone please suggest where i`m going wrong or if theres any other action i need to do ? I dont really understand how the ShowinTaskbar property is affecting the focus mechanism , or whether this is how windows itself works. So far i`ve tried doing a Activate() , Focus() & BringtoFront() in Form Y but it doesnt work. SetParent isnt an option since it couples together their lifetimes i.e. if child crashes parent also crashes. Thanks in advance
-
Hi , I`ve just hit an interesting roadblock in my app & would really appreciate any help / feedback. The "bug" can be replicated easily. Basically, I have 2 forms running as 2 different processes , say Form X & Form Y. Their properties are : Form X : ShowinTaskbar = true , FixedToolWindow , Maximized. Form Y : Showintaskbar = false , Borderstyle.None , Normal We have methods on Form Y that can be invoked via Remoting to do Show(owner) , usually Form X ends up being the owner here. I`ve impleneted the IWin32Window interface and initialise it with my Form X`s handle (obtained via FindWindow) The issue is that Form Y can NEVER retain focus (say when u click on a text box in it) and focus always gets transferred to the owner Form X. I`m not really setting an Owner / Owned relationship between them formally, say , via AddOwnedForms in Form X or Form.Owner = FormX since i guess this doesnt work across processes. If we change the ShowInTaskbar property of Form X to false , or Form Y to true then there is no problem with the Focus. Can someone please suggest where i`m going wrong or if theres any other action i need to do ? I dont really understand how the ShowinTaskbar property is affecting the focus mechanism , or whether this is how windows itself works. So far i`ve tried doing a Activate() , Focus() & BringtoFront() in Form Y but it doesnt work. SetParent isnt an option since it couples together their lifetimes i.e. if child crashes parent also crashes. Thanks in advance
As far as i understand your problem that is when you call formY then it shows behind the formX or lost focus when you click on its controls if yes then you can solve it by 3 ways 1.use ShowDialog() 2. before calling FormY then set its TopMost property to true (perhaps it work) 3. write
this.Focus()
in Deactivate event of FormYBecoming Programmer...
-
As far as i understand your problem that is when you call formY then it shows behind the formX or lost focus when you click on its controls if yes then you can solve it by 3 ways 1.use ShowDialog() 2. before calling FormY then set its TopMost property to true (perhaps it work) 3. write
this.Focus()
in Deactivate event of FormYBecoming Programmer...
Hi xmen_xwk , many thanks 4 ur reply. Right now Form Y is being shown , thats not an issue. Actually what i`m trying todo here is make a set of Forms work together and we can interact with any form at any time even though they are in separate exe`s. For eg: , do like minimize together , toggle between various owned forms(1 owner form is controlling a set of other owned form`s being shown or hidden),display them in a predefined part of the screen etc.. * showdialog() is a good idea but if i do it then i must close the Form Y and only then i can interact with Form X right ? so the blocking call causes problems * Plus doing this.focus() in deactivate means i can never transfer control away from Form Y :) * All the forms are non-topmost bcoz then they will then be minimized and restored together. Would u suggest changing the TopMost value on various events like OnMinimize or LostFocus ? that sounds promising.will try that Theres a "hack" i`ve tried as below with some dummy form A : Form A (grand-owner) : Form X (Owner) : Form Y (Owned) All are topmost=false , Showintaskbar = true only for Form X and is false for others. This helps solve the Keyboard focus problem , but i cant really put a "dummy form" into the actual production system code. If its ok with u I could also mail a copy of the sample project for this issue.
-
Hi xmen_xwk , many thanks 4 ur reply. Right now Form Y is being shown , thats not an issue. Actually what i`m trying todo here is make a set of Forms work together and we can interact with any form at any time even though they are in separate exe`s. For eg: , do like minimize together , toggle between various owned forms(1 owner form is controlling a set of other owned form`s being shown or hidden),display them in a predefined part of the screen etc.. * showdialog() is a good idea but if i do it then i must close the Form Y and only then i can interact with Form X right ? so the blocking call causes problems * Plus doing this.focus() in deactivate means i can never transfer control away from Form Y :) * All the forms are non-topmost bcoz then they will then be minimized and restored together. Would u suggest changing the TopMost value on various events like OnMinimize or LostFocus ? that sounds promising.will try that Theres a "hack" i`ve tried as below with some dummy form A : Form A (grand-owner) : Form X (Owner) : Form Y (Owned) All are topmost=false , Showintaskbar = true only for Form X and is false for others. This helps solve the Keyboard focus problem , but i cant really put a "dummy form" into the actual production system code. If its ok with u I could also mail a copy of the sample project for this issue.
buddy your problem is strange for me because i still not understood what is the problem and what are you trying to do.... if you explain exact what you want (if you like) then it will be better to understand. i just understood that you want to interact in all 3 forms....
Becoming Programmer...
-
buddy your problem is strange for me because i still not understood what is the problem and what are you trying to do.... if you explain exact what you want (if you like) then it will be better to understand. i just understood that you want to interact in all 3 forms....
Becoming Programmer...
hi , just tried the options u`ve suggested... unfortunately the problem still remains :( ShowDialog() works but then i must close that form before interacting with any other forms. Was the sample i uploaded useful ?
-
hi , just tried the options u`ve suggested... unfortunately the problem still remains :( ShowDialog() works but then i must close that form before interacting with any other forms. Was the sample i uploaded useful ?