Hey, I'm trying to get a script where some C++ makes the window turn full-screen... And well, I'm finding it stupidly hard. Everything I search on Google just... Plain doesn't work, outdated code maybe?

Anyway
Code:
#include "stdafx.h"
#include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow);

bool m_bFullScreen = true;
DWORD dwStyle;

DEVMODE best;

bool FindBestDisplayMode(DEVMODE &best, DWORD width, DWORD height, DWORD bpp)
{
    DEVMODE dm = {0};
    dm.dmSize = sizeof(DEVMODE);

    DWORD n, maxFreq = 0;
    bool found = false;

    for (n = 0; EnumDisplaySettings(NULL, n, &dm); n++)
    {
        if ((dm.dmPelsWidth == width) && 
            (dm.dmPelsHeight == height) &&
            (dm.dmBitsPerPel == bpp))
        {
            found = true;

            if (dm.dmDisplayFrequency > maxFreq)
            {
                maxFreq = dm.dmDisplayFrequency;
                best = dm;
            }//if
        }//if
    }//for

    return found;
}//FindBestDisplayMode


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow){
	FindBestDisplayMode(best, 800, 600, 32);
	if(m_bFullScreen){
		if(ChangeDisplaySettings(&best, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL){
			MessageBox(NULL, L"Display mode failed", NULL, MB_OK);
			m_bFullScreen = false;
		}
	}

	if(m_bFullScreen){      
		dwStyle = WS_POPUP;
		MessageBox(NULL, L"Display mode not failed", NULL, MB_OK);
	}
	else{
		dwStyle = WS_OVERLAPPEDWINDOW;
		MessageBox(NULL, L"Display mode failed", NULL, MB_OK);
	}


    WNDCLASS wc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hInstance = hInstance;
    wc.lpfnWndProc = WndProc;
    wc.lpszClassName = L"ClassName";
    wc.lpszMenuName = 0;
    wc.style = CS_HREDRAW | CS_VREDRAW;

    RegisterClass(&wc);

    HWND hwnd = CreateWindow(
        L"ClassName",
		L"Title",
        dwStyle,
		0, 0,
        800, 600,
        NULL, NULL,
        hInstance, NULL
	);    
    ShowWindow(hwnd, iCmdShow );
    UpdateWindow(hwnd);

    MSG msg;

	while(GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam){
    switch(message){
		case WM_PAINT:{
            HDC hdc;
            PAINTSTRUCT ps;
            hdc = BeginPaint(hwnd, &ps);

            Ellipse(hdc, 20, 20, 160, 160);
            Rectangle(hdc, 50, 50, 90, 90);
            Rectangle(hdc, 200, 50, 140, 90);

            EndPaint(hwnd, &ps);
        }
        return 0;
        break;

		case WM_DESTROY:
	        PostQuitMessage(0) ;
		return 0;
		break;

    }
    return DefWindowProc(hwnd, message, wparam, lparam);
}
That is my code. I had been putting in the DEVMODE manually, but someone told me I should get a function to find out the values for me... Either way outputs the same result, my screen goes black - and then nothing happens. I have to turn my PC off and try again.

(I'm using Visual C++ 2008 Express Edition, running on Windows 7 - just in case that does make a difference)

I would really appreciate a hand, thanks if anyone can help