Code:
/*

Questions go here:

1. is a reference another word for handle?
2. research TCHAR datatype.
3. Difference between WNDCLASSEX and WNDCLASS?
   WNDCLASSEX is the newer one. There are more differences but for our purposes
   lets assume that the newer one is the "better one". 
*/

//always necessary to include windows.h for making windowed programs

#include <windows.h>
#include "stdafx.h"
#include <stdio.h>

//function prototypes

ATOM produceAndregisterClass();

int createAndShowWindow();

LRESULT CALLBACK WindowProcedure
    (HWND hwnd, unsigned int message, WPARAM wParam, LPARAM lParam);

//global variables follow

HINSTANCE hinst; //a reference to the application instance

HWND mainWindow; //this reference will eventually point to the main Window,
				 //once instantiated

TCHAR className[] = "myWindow"; //the name of the "class" which we will register

/* Main Steps 

1. Define a window "class". Populate a WND Class Ex structure.
2. Register the window class. Pass the WNDCLASSEX struct pointer to RegisterClassEx.
3. Provide a windows procedure. This is the function which will deal with the user's
   interaction with the window.
4. Create and show the window.
5. Put application into a "message loop". 

*/

//entry point into a windowed application is main 

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{

	printf("in main function");

	if ( produceAndregisterClass() == 0 )
		return -1; //producing and registering class did not work for whatever reason
				   //thus we will exit early.

	if ( createAndShowWindow () == 0 )
		return -1; //again, something went wrong so exit early.

	//message loop goes here

	BOOL bRet;

	MSG msg;

	while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
	{ 
		if (bRet == -1)
		{
        return -1;
		}
    else
    {
        TranslateMessage(&msg); 
        DispatchMessage(&msg); 
    }
}

	
	return 0;
}

ATOM produceAndregisterClass()
{

	//first let us populate a WNDCLASSEX struct. 
	//this struct contains all the details of windows we will display

	WNDCLASSEX windowClass;

	//set the size. when dealing with WNDCLASSEX structures, the RHS of the
	//code is always the same when setting the cbSize member

	windowClass.cbSize = sizeof(WNDCLASSEX); 

	//a style helps determine the window's behavior. these are enumerated
	//at the MSDN website.
	//it is my understanding that using the | operator allows you to specify a combination of styles
	//I've set it to redraw the window whenever the height or width is adjusted.
	
	windowClass.style = CS_HREDRAW | CS_VREDRAW;

	//pointer to the programmer defined window procedure to deal with the user interaction with window

	windowClass.lpfnWndProc = (WNDPROC) WindowProcedure; 

	//number of extra bytes to allocate to structure. i'm saying 0 because this is a simple window,
	//although it remains to be seen exactly how you work how much more you need if the window was
	//"complex".

	windowClass.cbClsExtra = 0;

	//assign the reference to the application instance

	windowClass.hInstance = hinst;

	//assignment of an icon. NULL means system provides default.

	windowClass.hIcon = 0;

	//assignment of cursor. NULL means default.

	windowClass.hCursor = 0;

	//background colour assignment, this can be a handle to a data type called HBRUSH or
	//alternatively it can be a specified colour (if the latter must cast to HBRUSH).
	//always must add 1 to chosen colour.

	windowClass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);

	//this should be a string pointing to a resource that specifies a menu. 
	//but a NULL value means no menu, which is what we want for this simple window.

	windowClass.lpszMenuName = 0;

	//assign the class name (which we've stored in a global variable)

	windowClass.lpszClassName = className;

    //i guess this icon member is for the icon your app should have when it is listed
	//in a directory. don't really know but its not that important. we'll just use NULL.

	windowClass.hIconSm = 0; 

	//The structure is filled and now we must register it.

	return RegisterClassEx(&windowClass);
}

//call this function to create and display window only after registering the class.

int createAndShowWindow()
{

mainWindow = CreateWindowEx(
							WS_EX_APPWINDOW,//window behavior
							className, 
							"Test Window", //title bar string
							WS_CAPTION, //style
							CW_USEDEFAULT, //x position
							CW_USEDEFAULT, //y position
							CW_USEDEFAULT, //width
							CW_USEDEFAULT, //height
							0, //handle to parent window, but there is no parent so...?
							0, //menu handle. null means use the one specified in class
							hinst, //handle instance
							0 //lparam value...not really sure what its for
							);

if ( !mainWindow ) return 0;

else return 1;

}

//this function always has this signature and it deals with the user interaction
//messages are passed from the operating system to this function which processes 
//the messages

LRESULT CALLBACK WindowProcedure
    (HWND hwnd, unsigned int message, WPARAM wParam, LPARAM lParam)

{

//the window will do nothing, except vanish when we ask it to
//if there is a message we have not dealt with in the case statement
//we use the defaultwindowprocedure called DefWindowPoc.

	switch (message)
    {
        case WM_DESTROY:
            PostQuitMessage (0);
            return 0;

    }
    return DefWindowProc (hwnd, message, wParam, lParam );

}
i'm using visual c++ 6.0 and i have made sure i chose win32 project (Not console app).

when i run the executable nothing at all happens. not even the very first line of the main function which is
Code:
printf("in main function");
i must be doing something trivial but for the life of me i can't see what.

any help would be appreciated. thanks.