Link to home
Start Free TrialLog in
Avatar of Confusioner
Confusioner

asked on

How do I 'bring to front' a .NET windows form?

Hi,

I have an MFC application which is calling a C++ .NET windows form (in managed mode).  The form displays but it appears behind the calling MFC program.

How do I make this windows form appear in front of all other windows?  I have tried using newDlg->BringToFront() but this does not work.
#pragma managed
void EventingDlg::customiseToolbar()
{
	Form1 ^ newDlg = gcnew Form1();
	newDlg->ShowDialog();
	newDlg->BringToFront();
}

Open in new window

Avatar of lucky_james
lucky_james
Flag of India image

does the comtrol of execution comes to newDlg->BringToFront(); statement during the life time of the dialog?...... can you please confirm that.
Avatar of Confusioner
Confusioner

ASKER

I'm not too sure what your asking here.  The form is definately been created, because it appears on the screen.

That should mean that BringToFront() is called as well, but it doesn't actually do anything
after showdialog() the next instruction is executed when the dialog closes.

try as :
#pragma managed
void EventingDlg::customiseToolbar()
{
        Form1 ^ newDlg = gcnew Form1();
        newDlg->BringToFront();
        newDlg->ShowDialog();
}

Open in new window

OK tried that, it's still displaying behind my other window.

I also tried putting this line in form1:
this->BringToFront();

but didn't work either.
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
evilrix,
Thanks! Exactly what I needed.
Very welcome.