Bah... I can't bear MSVC++ 7.0...

Anything and Everything about Uplink

Moderators: jelco, bert_the_turtle, Chris, Icepick, Rkiver

User avatar
Miah
level5
level5
Posts: 3155
Joined: Mon Oct 13, 2003 7:28 pm
Contact:

Postby Miah » Thu Feb 26, 2004 6:48 pm

I seem to be having some major issues with MSVC++, or at least the new version. Is seems that no matter what I do, I just can't make it do really really simple things, such as...

Code: Select all

#include <iostream.h>

main()
{
     cout<<"Hello World!\n";
     return 0;
}


But here's the kicker. I convert something much more advanced to 7.0, such as this here program that makes the Juila Set, and for some reason, it works like a charm.

I got to thinking that maybe I have to do something special to the files to make the simple DOS programs work, as that program isn't the only one that will compile, and that runs in windows. It's only the crap programs I'm having issues with.

Does anyone else expreience these issues?
Dr Know
level1
level1
Posts: 33
Joined: Fri Apr 04, 2003 9:41 pm

Postby Dr Know » Thu Feb 26, 2004 7:27 pm

C++ depricates the .h in the header file.  The new versions of MSVC don't support it at all.  Remove the ".h" and you should be good.  Anyway you should be getting some errors which tell you something to this effect.
User avatar
Miah
level5
level5
Posts: 3155
Joined: Mon Oct 13, 2003 7:28 pm
Contact:

Postby Miah » Thu Feb 26, 2004 7:34 pm

That would explain some things... but here's the other issue.

I start a new project, and all sorts of crap is already there...

Code: Select all

// test.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "test.h"
#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;// current instance
TCHAR szTitle[MAX_LOADSTRING];// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];// the main window class name

// Forward declarations of functions included in this code module:
ATOMMyRegisterClass(HINSTANCE hInstance);
BOOLInitInstance(HINSTANCE, int);
LRESULT CALLBACKWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACKAbout(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
 // TODO: Place code here.
MSG msg;
HACCEL hAccelTable;

// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_TEST, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TEST);

// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return (int) msg.wParam;
}



//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage are only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style= CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc= (WNDPROC)WndProc;
wcex.cbClsExtra= 0;
wcex.cbWndExtra= 0;
wcex.hInstance= hInstance;
wcex.hIcon= LoadIcon(hInstance, (LPCTSTR)IDI_TEST);
wcex.hCursor= LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName= (LPCTSTR)IDC_TEST;
wcex.lpszClassName= szWindowClass;
wcex.hIconSm= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

return RegisterClassEx(&wcex);
}

//
//   FUNCTION: InitInstance(HANDLE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

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

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND- process the application menu
//  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)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

switch (message)
{
case WM_COMMAND:
wmId    = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// Message handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}


What is this for? I just want a simple program...

(Edited by Miah Helpmann at 12:34 pm on Feb. 26, 2004)
Dr Know
level1
level1
Posts: 33
Joined: Fri Apr 04, 2003 9:41 pm

Postby Dr Know » Thu Feb 26, 2004 7:37 pm

You are starting a Win32 program, not a console program.  You should also just start an empty project if you don't want to have all the default stuff added.
User avatar
Miah
level5
level5
Posts: 3155
Joined: Mon Oct 13, 2003 7:28 pm
Contact:

Postby Miah » Thu Feb 26, 2004 7:42 pm

Hmm... that would do it...

Thanks Dr Know. :)
User avatar
Jackmn
level5
level5
Posts: 1378
Joined: Thu Feb 07, 2002 5:21 pm

Postby Jackmn » Thu Feb 26, 2004 9:56 pm

Quote: from Miah Helpmann on 5:48 pm on Feb. 26, 2004[br]I seem to be having some major issues with MSVC++, or at least the new version. Is seems that no matter what I do, I just can't make it do really really simple things, such as...

Code: Select all

#include <iostream.h>

main()
{
   cout<<"Hello World!\n";
   return 0;
}


But here's the kicker. I convert something much more advanced to 7.0, such as this here program that makes the Juila Set, and for some reason, it works like a charm.

I got to thinking that maybe I have to do something special to the files to make the simple DOS programs work, as that program isn't the only one that will compile, and that runs in windows. It's only the crap programs I'm having issues with.

Does anyone else expreience these issues?


Leaving the 'int' return type off main would do it.

And the program you posted later on is an MFC app. Don't use MFC, it's terribly bloated.
Spectere_uplink
level4
level4
Posts: 789
Joined: Wed Apr 24, 2002 9:38 pm
Location: Ohio, USA
Contact:

Postby Spectere_uplink » Fri Feb 27, 2004 2:13 am

To create a non-MFC app in MSVC++ 7, click on "application settings" on the wizard screen and it'll give you some more options.  That took me a while to figure out.  I dunno.  Buttons and tabs must be OMFG TOO UG-LAY for Microsoft to use.

Also, yes, leaving off the int in a C++ compiler will give you compiler errors.  Also, Dr Know, the ".h" includes for iostream and other std namespace libraries still exist in MSVC++ 7, they just generate compiler warnings when used (and probably don't exist at all in .NET 2003).
.what.

Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 4 guests