Solved

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

Posted on 2009-03-31
2
359 Views
Last Modified: 2013-12-03
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
Comment
Question by:laptop1vn
2 Comments
 
LVL 19

Accepted Solution

by:
alb66 earned 500 total points
ID: 24030367
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 24031571
>>>> 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
format the code in java 6 93
fizzArray  challenge 1 83
abstract class with all non abstract mentods 6 76
Explain Unit of Work pattern 2 62
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

778 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