Solved

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

Posted on 2007-11-22
7
528 Views
Last Modified: 2013-11-20
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

0
Comment
Question by:Confusioner
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:lucky_james
ID: 20333508
does the comtrol of execution comes to newDlg->BringToFront(); statement during the life time of the dialog?...... can you please confirm that.
0
 

Author Comment

by:Confusioner
ID: 20333529
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
0
 
LVL 7

Expert Comment

by:lucky_james
ID: 20333547
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

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:Confusioner
ID: 20333575
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.
0
 
LVL 40

Accepted Solution

by:
evilrix earned 500 total points
ID: 20333602
Have you tried setting TopMost property on the form to be true?

http://msdn2.microsoft.com/en-us/library/system.windows.window.topmost.aspx
0
 

Author Comment

by:Confusioner
ID: 20333628
evilrix,
Thanks! Exactly what I needed.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 20333638
Very welcome.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question