|
Hi,
I have created a simple MFC Dialog App with a button. I have also created a Win32 Console App.
Within the dialog app, on the OnClick function of the button, I need to make a call to the Win32 Console App executable. The call can just be to start the exe and pass in some command line parameters.
Does anybody know the correct way of calling this exe and passing in command line arguments.
Cheers
Rav
|
|
|
|
|
|
ShellExecute(NULL, "file.exe", "-param1 -param2", "path", SW_SHOW);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You can also use CreateProcess() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
This bit of code runs OK as a Win32 program:-
#include <iostream><br />
#include <fstream><br />
#include <string><br />
using namespace std;<br />
<br />
<br />
int main(int argc, char * argv[]) {<br />
string OutFile;<br />
fstream OutStream;<br />
<br />
cout << "Please enter output file name: " ;<br />
cin >> OutFile;<br />
<br />
OutStream.open(OutFile.c_str(), ios::out | ios::trunc);<br />
<br />
if(!OutStream) {<br />
cout << "Error open file " << OutFile << " for writing\n";<br />
return 1;<br />
}<br />
<br />
OutStream<<"It is easier to resist at the beginning than at the end.\n";<br />
OutStream <<" -- Leonardo da Vinci" << endl;<br />
<br />
OutStream.close();
cout << "Content written to " << OutFile <<".\n";<br />
return 0;<br />
}
But if I try the code in an MFC dialog application I get the following errors:-
c:\C_Example\DiagnosticsDlg.cpp(177): error C2039: '_open' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'
with [ _Elem=char, _Traits=std::char_traits<char> ]
c:\C_Example\DiagnosticsDlg.cpp(177): error C2039: 'truc' : is not a member of 'std::basic_ios<_Elem,_Traits>' with [_Elem=char, _Traits=std::char_traits<char>]
Now if I use the statement to create/open the file
ofstream OutStream(OutFile); // Open an output stream
That seems to work, but as file not closed (as error with OutStream.close() so it is empty when viewed.
Is it a Namespace problem with the MFC classes!?!
|
|
|
|
|
We can't see any of your include statements. You need to use the Format toolbar < and > options and pre and code around your code.
It is not a good idea to use:
using namespace std;
instead only specify the namespace(s) you are actually using. eg.
using std::ofstream;
using std::ostringstream;
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Sorry, finger trouble, the includes were:-
#include <fstream>
#include <iostream> Still get error
c:\C_Example\DiagnosticsDlg.cpp(224): error C2039: '_close' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'with [_Elem=char,_Traits=std::char_traits<char>]
i.e. Don't understand why problems with:-
OutStream.open(OutFile, ios::out | ios::trunc);
OutStream.close();
To get things working I need to create/open the stream as follows:-
m_cmySQLFileName.GetWindowText(strFileName);
strcpy(OutFile, strFileName);
ofstream OutStream(OutFile);
I have included the namespace suggestions,
Many thanks.
|
|
|
|
|
|
The < and > caused problems with the includes again!
#include fstream
#include iostream
|
|
|
|
|
I have been looking for a profiler/ performance analyzer app that will work ith VC++ projects similiar to the VB Watch 2 add on. I know the VB Watch 2 add on gives alot of details on where the perormance bottlenecks are down to the line of code, number of calls to functions and so on..
Does anybody know an equivalent for VC++, i have BoundsChecker, even though this is good it doesn't help with performance related issues.
Cheers!
|
|
|
|
|
|
VC++ 6.0 comes with a profiler: Build->Profile...
Why not use it?
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
member "open" of "fstream" and "wfstream" has only one Ansi type
void open(const char *s, ios_base::openmode mode =
ios_base::in | ios_base::out,
long protection = 0666);
that means if i use Standard C++ Library to open a unicode named file,it will fail.
why SCL not support unicode names fstream
Stick to C++
|
|
|
|
|
My application has three dialog boxes. the first one has three buttons, Load, Modify and cancel.Load is used to display a bitmap on to the second dialog box and modify to make changes to the bitmap displayed on the second dialog. i have successfully displayed the image on the second box but cant find a way to modify the bitmap and display it on the third dialog. By modify, i mean to change the number the pixel values and the width and height of the bitmap. i tried changing the object of CBitmap to which i am loading the image and the BITMAP structure also. But it doesnt seem to change at all. Can anyone please help me out of this.
|
|
|
|
|
Load the bitmap into 2 different CBitmaps, one for each dialog.
To change pixel values:
1) Select current CBitmap into a memory DC and use GDI drawing functions.
2) Restore memory DC to initial state.
3) Update bitmap in 3rd dialog (InvalidateRect...What ever).
To change the size:
1) Create a new CBitmap of the needed size and select it into a memeory DC.
2) Select current CBitmap into a memory DC.
3) Use StretchBlt (resize bitmap) to copy the current CBitmap to the new CBitmap. Or Use BitBlt to copy any piece (sub-rectnagle) of the current CBitmap to the new CBitmap.
4) Restore memory DCs to intial states.
5) Make the new CBitmap your current bitmap, then destroy previous CBitmap (unless undo is required).
6) Update bitmap in 3rd dialog (InvalidateRect...What ever).
Well thats a general outline of what is required based on your post.
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi there,
i'm using Teofilov's NTGraph control to show some 2D charts in my application.
Now I'd like the control get resized when dialog box is resized but I have no idea about how to do that....
Does anyone know how resizing such controls to keep the same aspect ratio as containing dialog box...?
Thanks in advance,
Almenara
|
|
|
|
|
The ActiveX wrapper class derivates from CWnd, so it can be used like any other control. You can use the MoveWindow function from CWnd for that purpose.
|
|
|
|
|
hi all,
I am building a system tray like utlity for a mfc dialog based application( infact property sheet based application). just like Date/Time Property sheet application. in system tray.
I have done following.
1. Initialize the NOTIFYICONDATA structure m_nidIconData
2. Declare and defined a called back function using a user defined message.
3. Calling Shell_NotifyIcon(NIM_ADD,&m_nidIconData)in InitDialog of PropertySheet class.
4. handing msg in call back function such as WM_MOUSEMOVE,WM_LBUTTONDOWN etc.
5. Calling Shell_NotifyIcon(NIM_DELETE,&m_nidIconData) in d'ctor of PropertySheet class.
When ever i moved my mouse message the tray icon gets disappeard.
Can someone throw light on the problem?
Thanks in Advance
Abhi Lahare
|
|
|
|
|
Suddenly all the console applications written using the wizard in Visual C++ 6.0 no longer finish with "Press any key to continue" so I have to use my own few lines of code to see the results.
What have I done
|
|
|
|
|
From where are you running the console applications?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have been running them from inside the Visual C++ development environment using the F5 key, however running the exec file directly has the same result.
Unfortunately I do not have any "old" console applications lying around that I am certain are working (eg that the file they were reading is still there etc )but the ones I have tried all seem to start up and then immediately close again with no message.
Could it be something that has changed in the operating system which is Windows XP? I believe that the service pack 2 updates may have been made since I last used a console application.
Alan Johnstone
|
|
|
|
|
It used to be that when you ran a console application from an already-open console window, the console window would remain open after the application exits. When you ran a console application from within the IDE, the console window would prompt you then close.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
To be honest I cannot remember what happens is you run outside IDE but something has definitely changed as an "Hello World" program run from within IDE runs and immediately closes. So either I have inadvertently set some switch within IDE or there has been a change in the operating system.
Alan Johnstone
|
|
|
|
|
add this in your code to pause temporarily your running program :
add this header :
<font color=#0000FF>#include</font> <conio.h>
and this where you want to stop :
getch();
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|