Click here to Skip to main content
15,888,301 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Obscure exception? Pin
Carl Mercier30-Jul-04 9:52
Carl Mercier30-Jul-04 9:52 
QuestionHow to install my assembly in client machine Pin
softp_vc21-Jul-04 0:55
softp_vc21-Jul-04 0:55 
AnswerRe: How to install my assembly in client machine Pin
sukesh.g21-Jul-04 3:06
sukesh.g21-Jul-04 3:06 
GeneralProcess.Start problems... Pin
Jan van den Baard21-Jul-04 0:03
professionalJan van den Baard21-Jul-04 0:03 
GeneralRe: Process.Start problems... Pin
Javier Lozano22-Jul-04 14:28
Javier Lozano22-Jul-04 14:28 
GeneralRe: Process.Start problems... Pin
Jan van den Baard22-Jul-04 19:19
professionalJan van den Baard22-Jul-04 19:19 
GeneralRe: Process.Start problems... Pin
partyganger29-Jul-04 15:08
partyganger29-Jul-04 15:08 
GeneralRe: Process.Start problems... Pin
Jan van den Baard29-Jul-04 19:43
professionalJan van den Baard29-Jul-04 19:43 
Further investigation has shown to me that the problem does not happen always. If I use Process.Start() to open a word or Excel document it does happen but if I open a text file it does not. When the problem occures the following happens:

1) Call Process.Start("somefile.doc");
2) The form receives a Form_Activated() event.

I should tell that the documents are opened via clicking in a treeview in which these files are listed.

I have found "sort of" a solution to the problem which pertains to calling SetForegroundWindow() on the MainWindowHandle of the created process when possible/necessary. Resulting in something like shown below. Sucks big time but it does the trick for now...

[DllImport("user32")]
private static extern IntPtr SetForegroundWindow( IntPtr hWnd );
[DllImport("user32")]
private static extern int GetAsyncKeyState( long vKey );

// prProc is the initiated process...
private void MainForm_Activated(object sender, System.EventArgs e)
{
	try
	{
		// A mouse button pressed? If so presume the window was
                // activated by the user.
		if (( GetAsyncKeyState( 0x01 /* VK_LBUTTON */ ) & ( 1 << 15 )) == ( 1 << 15 ) ||
		    ( GetAsyncKeyState( 0x02 /* VK_RBUTTON */ ) & ( 1 << 15 )) == ( 1 << 15 ) ||
		    ( GetAsyncKeyState( 0x04 /* VK_MBUTTON */ ) & ( 1 << 15 )) == ( 1 << 15 ))
		{
			// Will not be needed anymore...
			prProc = null;
		}
		else if ( prProc != null )
		{
			// Process still running?
			if ( prProc.HasExited == false ) 
				// Put it's window upfront.
				SetForegroundWindow( prProc.MainWindowHandle );
		        // No longer necessary.
			prProc = null;
		}
	}
	catch ( InvalidOperationException )
	{
                // We did a SetForgroundWindow() when the process died
                // if we get here...
	}
}


Thanks...

We are the all singing, all dancing crap of the world. - Tyler Durden
QuestionConverting SafeArray? Pin
So and So20-Jul-04 6:13
So and So20-Jul-04 6:13 
AnswerRe: Converting SafeArray? Pin
So and So20-Jul-04 8:44
So and So20-Jul-04 8:44 
Generalproblem in accessing a VC++ 6.0 ATL COM object via a .Net application Pin
vipul_vips20-Jul-04 5:19
vipul_vips20-Jul-04 5:19 
GeneralWeb Service Error in Debug Mode Pin
jobr1ch19-Jul-04 21:47
jobr1ch19-Jul-04 21:47 
GeneralForm Size Too Big Pin
myNameIsRon19-Jul-04 19:53
myNameIsRon19-Jul-04 19:53 
GeneralRe: Form Size Too Big Pin
Small Rat24-Jul-04 18:13
Small Rat24-Jul-04 18:13 
GeneralFreeze some columns in Datagrid Pin
Sreepathi19-Jul-04 17:15
Sreepathi19-Jul-04 17:15 
General.NET &amp; MFC Serialization Compability Pin
alexatn19-Jul-04 11:35
alexatn19-Jul-04 11:35 
GeneralRe: .NET &amp; MFC Serialization Compability Pin
mav.northwind19-Jul-04 21:35
mav.northwind19-Jul-04 21:35 
GeneralSyntax Coloring in .NET Pin
bneacetp19-Jul-04 10:54
bneacetp19-Jul-04 10:54 
GeneralPrinting using ExecWB gives error &quot;Trying to revoke a drop target ...&quot; Pin
alexatn16-Jul-04 12:02
alexatn16-Jul-04 12:02 
GeneralSpeech .NET Pin
Serge Lobko-Lobanovsky16-Jul-04 6:20
Serge Lobko-Lobanovsky16-Jul-04 6:20 
GeneralReplacement of In-place Activation Pin
Aamir Butt15-Jul-04 23:56
Aamir Butt15-Jul-04 23:56 
GeneralRe: Replacement of In-place Activation Pin
mav.northwind17-Jul-04 4:28
mav.northwind17-Jul-04 4:28 
GeneralRe: Replacement of In-place Activation Pin
Aamir Butt18-Jul-04 18:17
Aamir Butt18-Jul-04 18:17 
GeneralListView icon disappear Pin
ting66815-Jul-04 4:24
ting66815-Jul-04 4:24 
GeneralWindows mobile 2003 for Pocket PC Pin
Member 123796715-Jul-04 3:37
Member 123796715-Jul-04 3:37 

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.