Hi Mikhail,
Thanks for your reply!
My test code works properly on my system (a WinXP box), here is the
complete test code. You may try my test code on your system, On my system
the new form will not get activated (although it is show in front of the
mainform), is it the effect you desired?
If it works, you may compare my test code with yours to see if there is any
difference, If you still have problem or it doesn't work for you, please
send me a simple sample based on your test code, I'd like to do some
research on it. Please remove word "online" before send the sample to my
e-mail box.
Thanks!
<code>
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.ComponentModel;
namespace project1
{
public class test
{
[STAThread]
public static void Main(String[] args)
{
Form f = new MyForm();
Application.Run(f);
}
}
class MyForm : Form
{
private Button btn = new Button();
public MyForm()
{
btn = new Button();
btn.Text = "New Form";
btn.Click += new EventHandler(btn_Click);
Controls.Add(btn);
}
private void btn_Click(object sender, EventArgs e)
{
NoActivateForm f = new NoActivateForm();
f.Show();
}
}
class NoActivateForm : Form
{
Control t;
public NoActivateForm()
{
t = new TreeView();
Controls.Add(t);
t.Show();
}
public void ShowNoActivate()
{
ShowWindow(Handle,4);//SW_SHOWNOACTIVATE
}
protected override void SetVisibleCore(bool value)
{
if (value)
{
ShowWindow(Handle,4);//SW_SHOWNOACTIVATE
}
else base.SetVisibleCore (value);
}
[DllImport("user32.dll")]
private extern static int ShowWindow(IntPtr hWnd,int nCmdShow);
}
}
</code>
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.