Help with mfc

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
Locked
Anonymous

Help with mfc

Post by Anonymous »

hi
I have two mfc applications.i want to execute the 2nd mfc application by clicking on any button on the toolbar in the first mfc application.

thanks in advance
archana

Archived topic from Iceteks, old topic ID:2154, old post ID:18315
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

Help with mfc

Post by Red Squirrel »

Welcome to the forum!

I have not programmed mfc in long, but I think you can still use the win32 winexec(); function. I think for mfc you need to put ::winexec() or something, I forget how it works.

Archived topic from Iceteks, old topic ID:2154, old post ID:18316
Honk if you love Jesus, text if you want to meet Him!
Fat Cat
Posts: 16
Joined: Wed Mar 31, 2004 8:33 pm

Help with mfc

Post by Fat Cat »

Can you use the "ShellExecute" command ?
I use this to call up IE and link to a web page from clicking a button on a Dialog Box in an MFC application. If your second application is an executable (.exe) it should work.


add your button/menu item and then double click on it in the C++ editior to jump to the place to enter the source code to run when the item is selected.

Below is an example of the code I use (but of course mywebsite.com isn't a real site)

void CAboutDlg::OnWebLinkMine()
{
ShellExecute(0, "open", "http://www.mywebsite.com", NULL, NULL, SW_SHOWNORMAL);
}

Archived topic from Iceteks, old topic ID:2154, old post ID:18637
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

Help with mfc

Post by Red Squirrel »

Forgot about that one. That's usefull because you can use the command of choice, so if you have a file type that has an open option but also an edit option, you can specify which one to use.

Archived topic from Iceteks, old topic ID:2154, old post ID:18638
Honk if you love Jesus, text if you want to meet Him!
Fat Cat
Posts: 16
Joined: Wed Mar 31, 2004 8:33 pm

Help with mfc

Post by Fat Cat »

ShellExecute works by opening the filename specified with whatever program is associated with that file type in your registry. If you specify a filename with a .xls extension for eaxmple, it will check the registry and find the application Excel listed under ther shell subkey and then go and open the file with Excel.

To execute an application (.exe file) that doesn't have a filetype associated with it needs a bit of cheating. It can be done by creating a simple text file, saving it with a unique file extension and then associating that extension with your mfc application (ie: right click on the file and use the Open With option and choose the always open these types of files with .... your mfc application).

Now back in your source code, you just enter the filename of the file you just associated with your mfc app. It will now launch your mfc app when clicked on and try to open the file. It doesn'tatter that the file can't be opened by the app, the app will still be left running.

I'f I discover the correct way to link to executables, I'll post it

Archived topic from Iceteks, old topic ID:2154, old post ID:18640
Locked