Reputation: 11
I've spent most of my day trying to figure out why this error is occurring but it continues to mystify me.
I created a console application in Visual C++ and created one MFC application.Now, I want to add them into single project such way that when i compile the project ,it should open the console then will open Dialog box depending upon my commands......
I've added afx headers files,set configuration settings.
I want to know where to start whether starting point would in winmain() or int main()? Is there any examples.? Give me some links to know. the solution Thank you in advance.
Upvotes: 1
Views: 1273
Reputation: 43311
Create MFC dialog-based application. Project - Properties - Configuration Properies- Linker - Advanced - Entry Point, set wWinMainCRTStartup (assuming that project is Unicode). Linker - System - select Console. Build application. Now it opens Console window and the dialog from it.
Add some logic. For example, in my Application class cpp file I added the following:
#include "stdafx.h"
#include "testmfc.h"
#include "testmfcDlg.h"
#include <iostream> // add
#include <string> // add
using namespace std; // add
...
BOOL CtestmfcApp::InitInstance()
{
...
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
// ****** add this
string s;
cout << "Start application?" << endl;
cin >> s;
if ( s == "y" )
{
CtestmfcDlg dlg;
m_pMainWnd = &dlg;
dlg.DoModal();
}
// ******
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}
return FALSE;
}
Now run application. If you answer "y" in the Console window, dialog is shown. Otherwise, application exits immediately. Implement your own logic based on this sample.
Upvotes: 2