How to merge c++ code into Visual C++ studio project?

I have created Win32 Application project in Visual C++ 2010 and I want to add C++ Program to display the word "Hello World" on the screen.
I have read many Forums but I cant get what I want. They endup proposing another code-type instead of pure C++ code.
Please help!!!!!!
Just Made this for you -

1. http://gyazo.com/fe937fa7cb9d6cc081f7347085f704e4

Now Click Okay. Then Click Next.

2. http://gyazo.com/d29207f13e77420ce5ea80efafe3ec10

Choose these exact settings. Press Finish.

Now on the right. Right click on Source Files. Click Add New Item.

http://gyazo.com/69c3e3546e5599778091ba5ed5648d1c

Select C++ File. Name it main.cpp. Then click Add.

And now last but not least -

http://gyazo.com/38597e5beff3567d89f88de2139e9412

And to finish this off. Dont use visual studio 2010, Get visual studio 2013.
Well thanks but!
When you Build it, it fails and Cant debug and give the following Errors messages:
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.07
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped

The same error happens when I tried to create Win32 Project then add someC++ code onto it using the same procedure.
Can I know why youre using VS 2010? Can you get 13?
I have windows 7, I couldnt install it in windows 7
However If I create empty project and then Add new Item to the Project and Choose C++ File(cpp) It works and displays something as if am on the normal c++ Command Windows of c++ compillers. This is not my aim.
What i WANT IS after creating a project let say WindowsForms then I should be able to add new item as c++ code so that it interacts with the forms or anyother project so created
Its really hard to understand what you're actually asking for. If you mean adding code/files that already exist, instead of adding a new item. Add "existing file".
Let us take a simple example, Create a WIN32 APP and then add C++ cod, if you DEBUG it gives ERRORS as BUILD failed? How to get rid of this error???
If you follow the guide in the video, you should not get any error.

What errors are you getting? because this

1>Build FAILED.
1>
1>Time Elapsed 00:00:01.07
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped


Shows 0 errors.
Absolutely!
If you follow the procedure on the video it gives no errors.
But that is for empty project!
If you Create Win32 Applications or Windows Forms Applications or anyother Application apart from Empty Application it throws some errors!
If you use this code here from Microsoft in the EMPTY PROJECT it displays the MESSAGE as I requested, but I want the opposed, the code should purely be of C++ and not otherwise

//Codee

// GT_HelloWorldWin32.cpp
// compile with: /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c

#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>

// Global variables

// The main window class name.
static TCHAR szWindowClass[] = _T("win32app");

// The string that appears in the application's title bar.
static TCHAR szTitle[] = _T("Win32 Guided Tour Application");

HINSTANCE hInst;

// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));

if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("Win32 Guided Tour"),
NULL);

return 1;
}

hInst = hInstance; // Store instance handle in our global variable

// The parameters to CreateWindow explained:
// szWindowClass: the name of the application
// szTitle: the text that appears in the title bar
// WS_OVERLAPPEDWINDOW: the type of window to create
// CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
// 500, 100: initial size (width, length)
// NULL: the parent of this window
// NULL: this application does not have a menu bar
// hInstance: the first parameter from WinMain
// NULL: not used in this application
HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
500, 100,
NULL,
NULL,
hInstance,
NULL
);

if (!hWnd)
{
MessageBox(NULL,
_T("Call to CreateWindow failed!"),
_T("Win32 Guided Tour"),
NULL);

return 1;
}

// The parameters to ShowWindow explained:
// hWnd: the value returned from CreateWindow
// nCmdShow: the fourth parameter from WinMain
ShowWindow(hWnd,
nCmdShow);
UpdateWindow(hWnd);

// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return (int) msg.wParam;
}

//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Hello, World!");

switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);

// Here your application is laid out.
// For this introduction, we just print out "Hello, World!"
// in the top left corner.
TextOut(hdc,
5, 5,
greeting, _tcslen(greeting));
// End application-specific layout section.

EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}

return 0;
}
//End of this code.

I want to have Win32 Application and then add C++ Code on it so that the screen will display what I want
If thats window programming. Post in the window section, not here. They can help you more.
How are you trying to display the text?
Topic archived. No new replies allowed.