15 Replies - 9172 Views - Last Post: 18 July 2009 - 02:12 PM
#1
Make Form always on top and can't Focus off
Posted 17 July 2009 - 07:10 AM
I Have a About Form and a Change Log form which get selected from the Help Menu.
How can i make it so when i click on the forms it locks them so people cant click on the main form and have to click ok to close the form before they can use the main form again rather then them clicking on the main form and hiding the about and change log form.
If you can just give me a link to somewhere where i can read about it. would be great not asking to do my code unless it just 1 line.
Regards
Richard
Replies To: Make Form always on top and can't Focus off
#2
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 07:48 AM
this.TopMost = true;
not sure about the focus thing
if i helped you can thank me by clicking the button below saying that this post was helpful for you
This post has been edited by Bocard: 17 July 2009 - 07:49 AM
#3
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 09:58 AM
MyForm frm = new MyForm(); if (frm.ShowDialog() == DialogResults.OK) // continue to main form else // close application or something
MyForm:
public partial class MyForm : Form {
public MyForm() {
InitializeComponent();
btnOK.DialogResult = DialogResult.OK;
}
}
It's important to set the DialogResult property of button so the main form knows what DialogResult is returned.
#4
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 10:00 AM
#5
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 11:53 AM
#6
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 11:55 AM
janne_panne, on 17 Jul, 2009 - 07:53 PM, said:
oh, sorry. i thought he wanted not to be able to lose focus at all from his form.
#7
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 12:35 PM
#8
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 01:01 PM
just put this.TopMost = true; in that event
if there is no event you can make another thread run a loop and set the form topmost, and pause for a few miliseconds so your not using a billion cpu
if this.TopMost = true doesnt work, use the SetForegroundWindow api
This post has been edited by firexware: 17 July 2009 - 01:02 PM
#9
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 01:01 PM
As for not being able to click anything else, I think putting everything in a DialogBox would be easiest, but that's just one opinion.
#10
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 01:15 PM
#11
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 02:56 PM
might be me it's past midnight here..00:56..i'm really tired
#12
Re: Make Form always on top and can't Focus off
Posted 17 July 2009 - 05:21 PM
#13
Re: Make Form always on top and can't Focus off
Posted 18 July 2009 - 05:21 AM
#14
Re: Make Form always on top and can't Focus off
Posted 18 July 2009 - 05:52 AM
#15
Re: Make Form always on top and can't Focus off
Posted 18 July 2009 - 05:56 AM
|
|

New Topic/Question
Reply




MultiQuote








|