Solved

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

Posted on 2007-11-22
7
525 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
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 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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now