Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Windows calculator

Posted on 2002-05-05
8
Medium Priority
?
194 Views
Last Modified: 2010-04-04
Hi there,

To use the calculator from Windows, I use the following line:

ShellExecute(0,nil,pchar('C:\WINDOWS\CALC.EXE'),nil,nil,sw_shownormal);

This is working fine...

Now I have the following question: Before I execute this calculator I want to check if there is already an instance active. And if there is already a calculator active then I would like to set the focus on that one. In other words: not opening a new instance anymore. If minimized then (of course) I would like to maximize before setting the focus on the calculator.

Please provide me with a complete example.

Thank you very much!

RoosieDB
0
Comment
Question by:roosiedb
[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
  • +1
8 Comments
 
LVL 8

Accepted Solution

by:
Cesario earned 100 total points
ID: 6990574
Hi RoosieDb,

procedure TForm1.Button1Click(Sender: TObject);
VAR
  hCalc : THandle;
begin
  // In Germany is the Caption of Calculator Window is "Rechner" so
  // you have to change it to Calculator
  HCalc := FindWindow ( NIL,'Rechner');
  IF HCalc <> 0 Then
  Begin
    Windows.SetForegroundWindow (hCalc);
    Windows.ShowWindow (hCalc,sw_normal);
  End
  Else ShellExecute(Handle,'OPEN','C:\Windows\CALC.EXE',nil,nil,sw_shownormal);
end;


Good Luck

Cesario
0
 
LVL 17

Expert Comment

by:inthe
ID: 6990588
or use classname instead of caption as this should be same for all languages:

HCalc := FindWindow( SciCalc,nil);

0
 
LVL 8

Expert Comment

by:Cesario
ID: 6990589
inthe, did you recieved any mail Notifications form ExEx last 3 days?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Expert Comment

by:inthe
ID: 6990717
hi Cesario,
was just wondering same thing myself.
well i guess Crazyone answered us :)
0
 

Author Comment

by:roosiedb
ID: 7065411
Hi Cesario,

Your solution is working fine, however, I would like to implement your example in my application without changing it everytime when my users are using different languages.

So, if you can send me a solution to solve that issue I would be very happy. But it's not required, because this is already working for me.

Your colleague wrote something like HCalc := FindWindow(SciCalc,nil), but this is not working (error message).

Thank you anyway.
RoosieDB
0
 
LVL 8

Expert Comment

by:Cesario
ID: 7066751
Hi RossieDB,

I will try to find a solution today....

Best Regrads

Cesario
0
 

Author Comment

by:roosiedb
ID: 7067135
Hi Cesario,

I would be very grateful...
:-)

In other words: Danke sehr !!

RoosieDB
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

715 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