Click here to Skip to main content
15,885,869 members
Home / Discussions / C#
   

C#

 
QuestionDetect if ANY control is clicked inside a form Pin
Dennis Bork3-Dec-12 3:05
Dennis Bork3-Dec-12 3:05 
QuestionRe: Detect if ANY control is clicked inside a form Pin
Richard Deeming3-Dec-12 3:10
mveRichard Deeming3-Dec-12 3:10 
AnswerRe: Detect if ANY control is clicked inside a form Pin
Dennis Bork3-Dec-12 3:14
Dennis Bork3-Dec-12 3:14 
SuggestionRe: Detect if ANY control is clicked inside a form Pin
Richard Deeming3-Dec-12 3:25
mveRichard Deeming3-Dec-12 3:25 
AnswerRe: Detect if ANY control is clicked inside a form Pin
Simon_Whale3-Dec-12 3:45
Simon_Whale3-Dec-12 3:45 
GeneralRe: Detect if ANY control is clicked inside a form Pin
Thomas Daniels3-Dec-12 7:28
mentorThomas Daniels3-Dec-12 7:28 
AnswerRe: Detect if ANY control is clicked inside a form Pin
DaveyM693-Dec-12 5:02
professionalDaveyM693-Dec-12 5:02 
Question[SOLVED] Setting the focus back to the window which had it last Pin
Dennis Bork3-Dec-12 2:33
Dennis Bork3-Dec-12 2:33 
--alright, the code below worked fine for a DirectX fullscreen app if I put ...SetForeGroundWindow(FindWindow("windowName"))...--

Hello all, I'm looking for a way to set the focus back to the last window that had it. For example I'm running a fullscreen app and I've got myForm always on top (topMost = true). But the window in the background shall have the focus back after I clicked once into myForm.

What I've already got is:

[DllImport("user32.dll")]
       extern static Boolean SetForegroundWindow(IntPtr windowName);

       [DllImport("user32.dll", SetLastError = true)]
       static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

       [DllImport("user32.dll")]
       extern static IntPtr SetActiveWindow(IntPtr windowName);



       private void btnDebugFocus_Click(object sender, EventArgs e)
       {
           String window =" aspecificname";            SetActiveWindow(FindWindow(window));            SetForegroundWindow(FindWindow(window));
       }


First, how do I figure out a windows' name? (Edit: not needed as I know the name) - If I put the windows' name I want to have the focus instead of "aspecificname" I get a runtime error as soon as the method is run.

The name of the window I want to have focus will always remain the same. Maybe somebody could help out,

Cheers
Dennis

modified 3-Dec-12 8:50am.

QuestionAD Directory catastrophic failure Pin
MacUseless2-Dec-12 21:56
MacUseless2-Dec-12 21:56 
AnswerRe: AD Directory catastrophic failure Pin
Dave Kreskowiak3-Dec-12 2:20
mveDave Kreskowiak3-Dec-12 2:20 
AnswerRe: AD Directory catastrophic failure Pin
Jason Gleim3-Dec-12 10:05
professionalJason Gleim3-Dec-12 10:05 
GeneralRe: AD Directory catastrophic failure Pin
MacUseless3-Dec-12 20:34
MacUseless3-Dec-12 20:34 
QuestionTFS 2010 : Email alerts are not working Pin
NarVish2-Dec-12 21:04
NarVish2-Dec-12 21:04 
AnswerRe: TFS 2010 : Email alerts are not working Pin
Richard MacCutchan2-Dec-12 21:52
mveRichard MacCutchan2-Dec-12 21:52 
GeneralRe: TFS 2010 : Email alerts are not working Pin
NarVish2-Dec-12 21:59
NarVish2-Dec-12 21:59 
AnswerRe: TFS 2010 : Email alerts are not working Pin
Pete O'Hanlon2-Dec-12 21:53
mvePete O'Hanlon2-Dec-12 21:53 
QuestionThesis project Pin
khinn Lyndon Samson2-Dec-12 19:46
khinn Lyndon Samson2-Dec-12 19:46 
AnswerRe: Thesis project Pin
Pete O'Hanlon2-Dec-12 21:18
mvePete O'Hanlon2-Dec-12 21:18 
AnswerRe: Thesis project Pin
Abhinav S2-Dec-12 22:05
Abhinav S2-Dec-12 22:05 
QuestionUDF 64bit vs 32bit Excel 2010 Pin
PozzaVecia2-Dec-12 4:39
PozzaVecia2-Dec-12 4:39 
RantRe: UDF 64bit vs 32bit Excel 2010 Pin
Mycroft Holmes2-Dec-12 11:36
professionalMycroft Holmes2-Dec-12 11:36 
GeneralRe: UDF 64bit vs 32bit Excel 2010 Pin
Richard MacCutchan2-Dec-12 21:48
mveRichard MacCutchan2-Dec-12 21:48 
Questiondetermine listbox items origin Pin
User 94041061-Dec-12 11:40
User 94041061-Dec-12 11:40 
AnswerRe: determine listbox items origin Pin
Mycroft Holmes1-Dec-12 13:04
professionalMycroft Holmes1-Dec-12 13:04 
AnswerRe: determine listbox items origin Pin
Freak303-Dec-12 0:53
Freak303-Dec-12 0:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.