• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

How to activate MDI program on TOP MOST (MFC)?

I have MDI program, MFC, with one exe file, ex: mypro.exe

When I click mypro.exe, it run, and I program it to run one time only. (that is, when click second time or more to myprog.exe, it do not run because it's running already!)

But I want: when click second time or more, if IT not ON TOP MOST, It will become ON TOP MOST!

How to do that!

Thanks!
0
laptop1vn
Asked:
laptop1vn
1 Solution
 
itsmeandnobodyelseCommented:
>>>> when click second time or more, if IT not ON TOP MOST, It will become ON TOP MOST!

Before terminating your second instance you could send a WM_ACTIVATE message to the top level window of your first instance. You could get the hwnd of the first instance either by enumerating the processes or the top level windows. Or if you have a p2p connection to your first instance anyhow (depends on how you found out that a previous instance exists) you could use that p2p to trigger your predecessor to make itself topmost (normally a SetFocus or handling the WM_ACTIVATE should be sufficient to get it top-most).
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now