Learn how to a build a cloud-first strategyRegister Now

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

linking 2 projects?

dear experts,
i did 2 projects and saved them in 2 different folder(workspace) or whatever it is called. how do i connect the two? i want to put a menu item in one of the project, when click on the menu item will open the second project. i hope this question is clear enough. pls mail me if u need more info to answer this question. i desperately need help here.
keanclaude@yahoo.com

0
kean082198
Asked:
kean082198
  • 6
  • 5
1 Solution
 
Answers2000Commented:
can you explain if this "link" is supposed to be at runtime or compile time.

If it's runtime

i. Add a menu option to project A
ii. Add a handler function for the menu in project A
iii. In the handler WinExec( "projectb.exe", SW_SHOWNORMAL ) ; to run the second project.  I recommend checking the return value (<=32 is an error)
0
 
antonio_m_barrosCommented:
On the other hand, if "link" is having both projects opened then

i) Select one of the workspaces
ii) Insert the other project into the first workspace (Menu Project, option Insert Project into Workspace)
iii) with the build toolbar visible, you will see a combobox (the first one) that will allow you to change from one project to the other, in teh same workspace.

0
 
kean082198Author Commented:
dear answer2000 and barros',
what i meant was that, i want a menu item on project A, when clicked will open project B to be run during the run time. well, i want to make an exe file out of it so i can combine the two files together( is this called run time?).
i thought it was like clicking the menu item to open a dialog box for input of data?, but in this case just opening the other project only?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kean082198Author Commented:
dear answer2000
what do you mean by checking the return value?
0
 
Answers2000Commented:
Are A and B both EXEs ?  My original comment assumed they were.  To expand on this

(you also said in a dummy question:

"Dear answer2000,
i think i you know what i mean here. can you please give me the more detailed solution onto how to do it. what is the complete code that is needed to write in the message handler in the project A. is it that i put it in the CMAinFrm.cpp or in the CView.cpp class? "

You can add the menu option to run another program, in either of the places you mentioned, or in the document.   MFC will handle it for you.  The normal way to choose where to put it would be:

(1) In the frame: if the menu option is available all the time (even if no documents are open)

(ii) In the document: if the menu option applies the same to all views of all documents

(iii) In the view: if the menu option applies to only a particular view (for example you may have 2 views of the same document which are supposed to react differently).

If you have an SDI app (1 doc, 1 view) it doesn't really matter.

Okay here's what to do
A. Add the menu option to your resources.
B. Use Class Wizard to add the handler for the menu option to your chosen class (you'll see a list of menu options in the "Object Ids" list box on message maps, add a "COMMAND" handler).
C. You'll get a function added to the bottom of the C++ file something like

void CMyMainFrame::OnFileRun()
{
      // TODO: Add your command handler code here
      
}


Inside the brackets put the code to run the second program, example:

void CMyMainFrame::OnFileRun()
{
   UINT nError = WinExec( "C:\SOMEDIR\B.EXE", SW_SHOWNORMAL ) ;

   if ( nError <= 31 )
   {
       CString strError ;
       strError.Format( "Couldn't start B\n\nError %u", (unsigned)nError ) ;
       AfxMessageBox( strError ) ;
   }
}

0
 
kean082198Author Commented:
dear answer2000,
i followed exactly what you told me to do. i put the menu item
added a msg handler then put in the codes. but the error box came out
instead.
must i put the second project in the first project first?
or should i import it inside my first project.

please explain further.
what came out was...error 2???

my second project name is saved in this folder:
D:\ProgramFiles\DevStudio\MyProjects\Signature

please tell me what is my next step. i am quite weak in this
programming language.
0
 
Answers2000Commented:
Remember the EXE from the 2nd project is not necessarily where you think it is

Typically the output from a project goes into a DEBUG or RELEASE directory, which is a subdirectory of the main project directory

Make sure you specify the path to the 2nd EXE correctly (you can look where it is by using Windows Explorer after building the 2nd project), or put both EXEs in the same directory (WinExec without just the EXE name e.g. "B.EXE" will work if this is the case)

Incidentally I notice you accepted antonio's answer - you don't have to accept the first answer that comes along - this was a mistake - right?
0
 
kean082198Author Commented:
dear ans2000,
thk you for all yr help. i didn't realise tht i accepted his answer. anyway, u have been great in identifying my error!
0
 
Answers2000Commented:
i shall ignore the dummy Q's unless you tell me otherwise
0
 
kean082198Author Commented:
dear ans2000,
one real dummy question....how do i go abt giving points to you? i feel that i really need to acknowledge your effort here. i manage to open the second project already..all thanks to you.
thank you very much. i really appreaciate all that u have done!
how can i personally thank you...?
kean
0
 
kean082198Author Commented:
dear answer2000,

is it possible to insert a picture in my dialog box, to enhance the
appearance of it? i know it is pretty simple to do it in visual basic
but i don't know how to do it in visual c++.
please give me some tips. i have the picture that i wanted to paste
in my dialog box saved in a file. please advice me on how to do it?
i just want to make the appearance better.
thank you.
btw, the linking of the files works fine.

kean
0
 
Answers2000Commented:
hi kean - I'll post this in all 3 Qs you have relating to "linking to 2 projects" although this follow up original came from "linking 2 projects Q"

>> one real dummy question....how do i go abt giving points to you? i feel that i really need to acknowledge your effort here. i manage to open the second project

I'll look the 2 dummy Qs you made.  You can then give me a grade if you like either (a) for both or (b) reject one and grade one, or (c) even if you want create another dummy if you want to allocate more

>> is it possible to insert a picture in my dialog box,
 Regarding the picture.
1.  Insert a bitmap on icon into your resources
2. Add a text control to the dialog resources
3. You can set the text style in resources to shown the picture.  Quite a few options there
If you have more Qs on this, you really should open up a new question, as I or other experts may not spot it a "dead" question like linking 2 projects



0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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