Advertising (This ad goes away for registered users. You can Login or Register)

Win32 API tutorial

Programming on your favorite platform, for your favorite platform? Post here
Post Reply
electrosheep
Posts: 97
Joined: Tue Jan 11, 2011 2:50 am

Win32 API tutorial

Post by electrosheep » Wed Sep 21, 2011 12:32 am

So I just came across a site that is the most interesting site I've found since this one.

This site contains a DirectX10 tutorial (as well as many other awesome things like neural networking), and one of the first things in the DirectX tutorial is, "The entry point of most 3D tutorials is win32".
Then, he recommends reading through this Win32 tutorial.

I've been looking around for some good tutorials about these topics for a while, so I figured I'd post this for others who may be interested.
Advertising
Let me see...your grandmother's name was Beatrice?

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Win32 API tutorial

Post by m0skit0 » Wed Sep 21, 2011 8:37 am

electrosheep wrote:"The entry point of most 3D tutorials is win32".
:?: :?: You mean for 3D for Windows...
Advertising
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

electrosheep
Posts: 97
Joined: Tue Jan 11, 2011 2:50 am

Re: Win32 API tutorial

Post by electrosheep » Wed Sep 21, 2011 3:53 pm

m0skit0 wrote: :?: :?: You mean for 3D for Windows...
It wasn't my statement, but I'm assuming that is what the author is talking about.

I ran into some trouble with some unicode *** on the second page of the tutorial, and in case anyone else has problems, here is my code that works

Code: Select all

#include <Windows.h>

const wchar_t g_szClassName[] = L"myWindowClass";

// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
	switch (msg){
	case WM_CLOSE:
		DestroyWindow(hwnd);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
	WNDCLASSEX wc;
	HWND hwnd;
	MSG Msg;

	//Step 1: Registering the Window Class
	wc.cbSize			= sizeof(WNDCLASSEX);
	wc.style			= 0;
	wc.lpfnWndProc		= WndProc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hInstance		= hInstance;
	wc.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName		= NULL;
	wc.lpszClassName	= g_szClassName;
	wc.hIconSm			= LoadIcon(NULL, IDI_APPLICATION);

	if (!RegisterClassEx(&wc)){
		MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	// Step 2: Creating the Window
	hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, L"The title of my window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL);

	if (hwnd == NULL){
		MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);

	// Step 3: The Message Loop
	while(GetMessage(&Msg, NULL, 0, 0) > 0){
		TranslateMessage(&Msg);
		DispatchMessage(&Msg);
	}
	return Msg.wParam;
}
Let me see...your grandmother's name was Beatrice?

Post Reply

Return to “Programming”