Ok, so...

//here we're making a structure which holds information about how we are gonna paint in the client area...

PAINTSTRUCT PaintSt;

//here we are calling the beginpaint function and passing its return value to the HDC variable. By calling this function im not too sure of what we're doing and why we pass its return value.

handleDeviceContext = BeginPaint(hWnd, &PaintSt);

//here we are drawing the icon on scren...

DrawIcon(handleDeviceContext, X, Y, hIcon);

//This function is called at the end of painting (not exactly sure why we have to tho)

EndPaint(hWnd, &PaintSt);