?
Solved

Help With Writing a program that will restore if it is already open

Posted on 2003-03-05
1
Medium Priority
?
222 Views
Last Modified: 2010-04-17
I am currently writing a program iin Visual C++ that runs in the backdrop and places a taskbar icon.  I have figured out how to place the taskbar icon and make the program restore if you click on the icon.  My problem now is that I wish to make it so that if you click on the desktop icon (like running the program again) instead of running another thread it just shows the form and transfers the focus to it.

I would really appreciate help
Thanks
MiDK
0
Comment
Question by:MiDK
[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
1 Comment
 
LVL 6

Accepted Solution

by:
PlanetCpp earned 320 total points
ID: 8076388
if you want a quick fix then you can just look for the other window.
in winmain before you create anything
HWND alreadythere = FindWindow(NULL,"your window's title");
alternately you can use
HWND alreadythere = FindWindow("mainwinclassname","");
if(alreadythere!=0)
{
//you said it was minimized so we restore it
ShowWindow(alreadythere,SW_RESTORE);
return 0; //exit winmain
}
//if i remember correctly when you restotre it the focus should go to that window.
this method isnt the greatest because other users can have your program running on there own accounts, but im guessing that not an issue.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

777 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