Bring anothe app to the front and an "Inside Application.Run" question

  • Thread starter Thread starter Academia
  • Start date Start date
A

Academia

I tried the code at the end of this note although

I didn't think it would work since

without and "Application.Run.."

I'm thinking there is no message loop

as I had found this on the internet:

This is a Win32 message (or wait loop)

while (GetMessage(&msg, NULL, 0, 0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

but in .NET, Application.Run is used instead,

it calls those same functions internally.

Some explanation of what is going on would be appreciated!

========================

What I need to know for my code is:

How to make another process come to the front.

I'd ask in the message box if I should bring the other app to the front.

If I can't bring it to the front can I flash it's title bar?

========================

THANKS



///

Using mutx As New Mutex(True, "App", mutexWasCreated)

If Not mutexWasCreated Then

MessageBox.Show("Can Not Start App", "App is already running",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

Return 1

End If

///
 
Academia said:
I tried the code at the end of this note although

I didn't think it would work since

without and "Application.Run.."

I'm thinking there is no message loop

as I had found this on the internet:

This is a Win32 message (or wait loop)

while (GetMessage(&msg, NULL, 0, 0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

but in .NET, Application.Run is used instead,

it calls those same functions internally.

Some explanation of what is going on would be appreciated!


Internally, the API function MessageBox is called. It is a modal dialog box:

http://msdn2.microsoft.com/en-us/library/ms644994(VS.85).aspx#modal_boxes

Read the 6th paragraph, stating that the system starts its own message loop.


Armin
 
I'd need another way to find the handle of the other process since I change
the MainWindowTitle depending on what the user is doing.



Thanks
 
That was interesting.
Especially the comments about dialog box owners.
I don't think I've been specifying the owner.

thanks
 
Back
Top