Graphics tutorial

This is a discussion on Graphics tutorial within the C++ Programming forums, part of the General Programming Boards category; Code: /* Trim fat from windows*/ #define WIN32_LEAN_AND_MEAN #pragma comment(linker, "/subsystem:windows") /* Pre-processor directives*/ #include "stdafx.h" #include <windows.h> /* Windows ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    255

    Graphics tutorial

    Code:
    /*	Trim fat from windows*/
    #define WIN32_LEAN_AND_MEAN	
    #pragma comment(linker, "/subsystem:windows")
    /*	Pre-processor directives*/
    #include "stdafx.h"
    #include <windows.h>
    /*	Windows Procedure Event Handler*/
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	PAINTSTRUCT paintStruct;
    	/*	Device Context*/
    	HDC hDC; 
    	/*	Text for display*/
    	char string[] = "Hello, World!"; 
    	/*	Switch message, condition that is met will execute*/
    	switch(message)
    	{
    		/*	Window is being created*/
    		case WM_CREATE: 
    			return 0;
    			break;
    		/*	Window is closing*/
    		case WM_CLOSE: 
    			PostQuitMessage(0);
    			return 0;
    			break;
    		/*	Window needs update*/
    		case WM_PAINT: 
    			hDC = BeginPaint(hwnd,&paintStruct);
    			/*	Set txt color to blue*/
    			SetTextColor(hDC, COLORREF(0x00FF0000));
    			/*	Display text in middle of window*/
    			TextOut(hDC,150,150,string,sizeof(string)-1);
    			EndPaint(hwnd, &paintStruct);
    			return 0;
    			break;
    		default:
    			break;
    	}
    	return (DefWindowProc(hwnd,message,wParam,lParam));
    }
    /*	Main function*/
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
    	WNDCLASSEX  windowClass;		//window class
    	HWND		hwnd;				//window handle
    	MSG			msg;				//message
    	bool		done;				//flag saying when app is complete
    	/*	Fill out the window class structure*/
    	windowClass.cbSize = sizeof(WNDCLASSEX);
    	windowClass.style = CS_HREDRAW | CS_VREDRAW;
    	windowClass.lpfnWndProc = WndProc;
    	windowClass.cbClsExtra = 0;
    	windowClass.cbWndExtra = 0;
    	windowClass.hInstance = hInstance;
    	windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    	windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    	windowClass.lpszMenuName = NULL;
    	windowClass.lpszClassName = "MyClass";
    	windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    	/*	Register window class*/
    	if (!RegisterClassEx(&windowClass))
    	{
    		return 0;
    	}
    	/*	Class registerd, so now create window*/
    	hwnd = CreateWindowEx(NULL,		//extended style
    		"MyClass",			//class name
    		"A Real Win App",		//app name
    		WS_OVERLAPPEDWINDOW |		//window style
    		WS_VISIBLE |
    		WS_SYSMENU,
    		100,100,			//x/y coords
    		400,400,			//width,height
    		NULL,				//handle to parent
    		NULL,				//handle to menu
    		hInstance,			//application instance
    		NULL);				//no extra parameter's
    	/*	Check if window creation failed*/
    	if (!hwnd)
    		return 0;
    	done = false; //initialize loop condition variable
    	/*	main message loop*/
    	while(!done)
    	{
    		PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE);
    		if (msg.message == WM_QUIT) //check for a quit message
    		{
    			done = true; //if found, quit app
    		}
    		else
    		{
    			/*	Translate and dispatch to event queue*/
    			TranslateMessage(&msg); 
    			DispatchMessage(&msg);
    		}
    	}
    	return msg.wParam;
    }
    this is the code to the graphics tutorial on the main site and to be honest IM COMPLETELY CONFUSED

    if someone could explain it a little better that would be great i jsut blantantly dont get it...i see the you can edit the color and location part and that char string part is the text but outside of that im pretty lost.

    could anyway maybe summarize this a little better cause id like to know graphics somewhat sooner or later lol

    since for a simple hello world program this is rather giant lol and since ive never done graphics programming before this is scarey looking

    sorry if this is a little vague of a question but just general clearing up is what is needed so thats why its vague sorry but thanks anyway
    hooch

  2. #2
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    LOL if your trying to learn Win32 Programming you should go here www.winprog.org
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Introductory Graphics in C, Info & Tutorial
    By Adak in forum Game Programming
    Replies: 5
    Last Post: 03-16-2009, 05:57 PM
  2. Tutorial for making better computer graphics?
    By supertoad in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 05-02-2005, 12:19 AM
  3. About the graphics tutorial hosted here..
    By Cobras2 in forum C++ Programming
    Replies: 4
    Last Post: 10-23-2002, 12:40 PM
  4. Graphics && Tutorial
    By GaPe in forum C Programming
    Replies: 2
    Last Post: 03-06-2002, 10:57 AM
  5. A Tutorial For Graphics In C!!!
    By SupremeOmnipotence in forum C Programming
    Replies: 4
    Last Post: 01-17-2002, 05:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21