Solved

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

Posted on 2007-11-22
7
529 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

733 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