Author Topic: Open dialog  (Read 4657 times)

Offline MikeR

  • Multiple posting newcomer
  • *
  • Posts: 11
    • 3DCentral
Open dialog
« on: August 28, 2005, 06:10:46 pm »
I have tried till I'm bald and can't figure out how to open another program from within a program.
What I'm trying to do is to have my users click on "open" in the tab, then it opens "notebook.exe". I just haven't figured out how to do this. Any suggestions?

I've tried:

system(../../notebook.exe);

(don't recall the other ways I've done this. There are too many to list anyway)

but it doesn't work. Compiles without errors, but doesn't work.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Open dialog
« Reply #1 on: August 28, 2005, 06:19:52 pm »
I have tried till I'm bald and can't figure out how to open another program from within a program.
What I'm trying to do is to have my users click on "open" in the tab, then it opens "notebook.exe". I just haven't figured out how to do this. Any suggestions?

I've tried:

system(../../notebook.exe);

(don't recall the other ways I've done this. There are too many to list anyway)

but it doesn't work. Compiles without errors, but doesn't work.


If you 're using windows, then lookup ShellExecute() ;)
(it can also "open" files, i.e. document.txt, page.htm, etc)
Be patient!
This bug will be fixed soon...

Offline MikeR

  • Multiple posting newcomer
  • *
  • Posts: 11
    • 3DCentral
Re: Open dialog
« Reply #2 on: August 28, 2005, 06:31:48 pm »
I'm using the standard C++ library.
I'll see what I can find on ShellExecute() Thanks.

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: Open dialog
« Reply #3 on: August 28, 2005, 07:43:55 pm »
I'd use system().  This is both portable (linux, windows) and passes all directory path handling to the system's shell, so that quotes ("") and spaces in pathnames are handled transparently.  You sure system("..\..\notebook.exe") or sytem("..\\..\\notebook.exe") are no good?


Offline MikeR

  • Multiple posting newcomer
  • *
  • Posts: 11
    • 3DCentral
Re: Open dialog
« Reply #4 on: August 28, 2005, 08:51:50 pm »
This is my code:

Code: [Select]
case 100: //File -> open
              // env->addFileOpenDialog(L"Please select a file to open");
               system("media/texteditor/MdiApp.exe");
               break;

It compiles, but doesn't work.

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: Open dialog
« Reply #5 on: August 28, 2005, 09:26:43 pm »
#include <iostream>

int main()
{
   std::cout << "Hello world!" << std::endl;
   system("folder\\notepad.exe");
   return 0;
}

directory structure:
c:\test
   console.exe
c:\test\folder
   notepad.exe

and then ran console.exe and it works.

Offline MikeR

  • Multiple posting newcomer
  • *
  • Posts: 11
    • 3DCentral
Re: Open dialog
« Reply #6 on: August 28, 2005, 10:01:24 pm »
Thankyou. :)
I tried it, but had to move the exe to the root folder to make it work. I'll keep playing with it becouse I know I really don't need it there. It is working tho. Many many thanks.

Edit to add: Fixed and working properly. Thanks.

« Last Edit: August 28, 2005, 10:45:37 pm by MikeR »