Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Hi C++ GURU's I have a question on launching applications within an application

Hello everyone,

this is my first post and with it a question.
How do you launch an application and have it run within your applications window.

Example:
I have a CScrollView class and I want to launch an app within that view lets say the calc app. Therefore when I use the scrollbar it scrolls the calc app. Also when I minimize/maximize the view the calc app reflects these changes.

Thank you in advance for the info.
Cheers
Jim
0
JimOliveira
Asked:
JimOliveira
  • 2
2 Solutions
 
PlanetCppCommented:
You can use SetParent
let's say you want to do this with calc.exe,
first off we need to get the handle to calc.exe that's runing now.
HWND calc = FindWindow("SciCalc","");
now where did that come from?
SciCalc is the classname to the main window in calc.exe
i got that by opening spy++ (a visual studio tool, or get any APISpy) when you click find window and hold that target icon over calcs window youll see the classname. handles change each time classnames do not change ever.
so now we have the hwnd assuming that calc.exe is running, add code to check if calc == 0
now you need the handle to the window you want to put calc in, lets sya you have that in the "scrollwin" variable
SetParent(calc,scrollwin);
and now calc will move to be inside your scrollwin window as a child, if you minimize scrollwin, calc goes with it and etc.
if you want to be able to set it back, setparent returns the previous parent of the handle you send it, so you can save it to return the window later.
make sure you DO NOT close your program without first closing the calculator. so save the handle, or better yet get it again (if you change the view to scientific or vice-versa the handle changes, watch for these things) then close calc before you close the scroll window or itll error in windows.
0
 
JimOliveiraAuthor Commented:
PlanetCpp

It seems that HWND calc = FindWindow("SciCalc","");
returns NULL.

Do you know what I am doing wrong?

Cheers
Jim
0
 
PlanetCppCommented:
as long as the calc program was running it should have returned the handle. if it was running then use spy++ and check thee main classname for calc, it was SciCalc on win xp.
0
 
CleanupPingCommented:
JimOliveira:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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