• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

Can C++Builder Form Application wait until termination on command prompt ?

Hello Experts,

C++Builder XE5, Windows 7 64bit

When I run C++Builder Form Application on command prompt, it returns immediately without waiting its termination.
I want to show some messages with fprintf(stderr or stdout) in my form application, but I don't know how to setup my form application.

Any hints welcome,
Nobuo Miwa
0
NobMiwa
Asked:
NobMiwa
  • 2
  • 2
  • 2
2 Solutions
 
chaauCommented:
You can "wait" for the program completion in the batch files using one of the following methods:
START /wait notepad.exe 

Open in new window

or
CALL notepad.exe 

Open in new window

Both of these commands will wait for the program to complete before proceeding to the next line.
If you call the program on its own, like this:
notepad.exe

Open in new window


The next line in the batch file will be executed immediately.
(NB: replace notepad.exe with the name and path of your program)
0
 
jkrCommented:
If you are creating a Windows GUI application (which I presume), there simply is no stdout or stderr. What you can do to display diagnostic information is using 'OutputDebugString()' (http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362(v=vs.85).aspx) and watch the output e.g. using "DebugView" (http://msdn.microsoft.com/en-us/vstudio/bb896647)

Alternatively you can of course wite your diagnostic output to a file using 'fprintf()', but I prefer the lhat method.
0
 
NobMiwaAuthor Commented:
Thanks quick advice,

I tried both, but that could not print string from printf("hello\n").
I want to print it in command prompt.

Regards,
Nobuo Miwa
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.

 
jkrCommented:
Again: When you are launching a GUI application, there is no command prompt. At least none related to that application. GUI apps just detach from command prompts, see the docs on 'CreateProcess()' (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx)
0
 
chaauCommented:
I think you need to read this article. It is a little bit dated, but in my opinion still relevant. The idea described in this article is to use a project for the console application and just create the Windows Form. The piece of code that creates the form in the console application is closer to the end of this article:
        // Create an instance of the TForm
        // class and show the form.
        TForm1* Form1 = new TForm1(0);
        int x = Form1->ShowModal();

        // Enable the console window and
        // bring it to the top.
        EnableWindow(hWnd, true);
        BringWindowToTop(hWnd);

        // Display the results of the modal form.
        cout << endl << "Modal result: " << x << endl;
        cout << endl <<  "Press any key to continue...";
        getch();
        delete Form1;

Open in new window

0
 
NobMiwaAuthor Commented:
Thank you for advice.
You let me know unknown things.
I will find out another way to return result of my app without printf().

Thank you again.
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.

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