>>> I am a complete idiot in programming
It is because the tutorials you are using are trying to address this point. They are programming tutorials, not Win32 API tutorials. If you cannot program, believe me, you can't program the Win32 API. You will need to be able to reasonably fluent with your language before you try otherwise, you will just get confused and be back here asking why "X" doesn't work, when you are simply doing it wrong.
Walk before you run, learn the alphabet before you start on poetry, the language, before the applications.
This is just about the simplest Windows program you can write.
Code:
#include <windows.h>
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
LPSTR Args, int WinMode)
{
HWND hWnd;
MSG Message;
WNDCLASSEX WinClass;
WinClass.cbSize = sizeof(WNDCLASSEX);
WinClass.hInstance = hThisInst;
WinClass.lpszClassName = "Window";
WinClass.lpfnWndProc = WindowFunc;
WinClass.style = 0;
WinClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WinClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
WinClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WinClass.lpszMenuName = NULL;
WinClass.cbClsExtra = 0;
WinClass.cbWndExtra = 0;
WinClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
if(!RegisterClassEx(&WinClass)) return 0;
hWnd = CreateWindow("Window",
"Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
HWND_DESKTOP,
NULL,
hThisInst,
NULL);
ShowWindow(hWnd,
WinMode);
UpdateWindow(hWnd);
while(GetMessage(&Message,
NULL,
0,
0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WindowFunc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT PaintStruct;
HDC hDC;
switch(Message)
{
case WM_PAINT:
hDC = BeginPaint(hWnd,
&PaintStruct);
TextOut(hDC,
10,
10,
"Hello Windows",
14);
EndPaint(hWnd,
&PaintStruct);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,
Message,
wParam,
lParam);
}
return 0;
}