Solved

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

Posted on 2007-11-22
7
530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

729 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