Code:
#include <windows.h>
#include <stdlib.h>
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
HINSTANCE hInstGlobal;
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
hInstGlobal = hInstance;
WNDCLASSEX WndCls;
static char szAppName[] = "Kazalio Studios";
MSG Msg;
WndCls.cbSize = sizeof(WndCls);
WndCls.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
WndCls.lpfnWndProc = WindProcedure;
WndCls.cbClsExtra = 0;
WndCls.cbWndExtra = 0;
WndCls.hInstance = hInstance;
WndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
WndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndCls.lpszMenuName = NULL;
WndCls.lpszClassName = szAppName;
WndCls.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
RegisterClassEx(&WndCls);
CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
szAppName, "Dog Simulator 2",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 600, 400,
NULL, NULL, hInstance, NULL);
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage( &Msg);
}
return static_cast<int>(Msg.wParam);
}
void dogname(HWND hWnd, WPARAM wParam, LPARAM lParam);
void credits(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
void startscrn(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT Ps;
HFONT font;
switch(Msg)
{
case WM_CREATE:
HWND hContinue, hExit, hCredits, hBack;
hContinue = CreateWindow ( "Button", "Continue",
WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON,
10, 320, 140, 20,
hWnd, (HMENU) 1,
hInstGlobal, NULL );
hExit = CreateWindow ( "Button", "Exit",
WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON,
437, 320, 140, 20,
hWnd, (HMENU) 2,
hInstGlobal, NULL);
hCredits = CreateWindow ( "Button", "Credits",
WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON,
225, 320, 140, 20,
hWnd, (HMENU) 3,
hInstGlobal, NULL);
return 0;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
if(LOWORD(wParam) == 1)
{
DestroyWindow(hContinue);
dogname(hWnd, wParam, lParam);
}
if(LOWORD(wParam) == 2)
{
SendMessage (GetParent((HWND)lParam),
WM_DESTROY, 0, 0);
}
if(LOWORD(wParam) == 3)
{
credits(hWnd, Msg, wParam, lParam);
}
}
if(HIWORD(credits) == BN_CLICKED)
{
if(LOWORD(credits) == 4)
{
startscrn(hWnd, wParam, lParam);
UpdateWindow(hWnd);
}
}
return 0;
case WM_PAINT:
hDC = BeginPaint(hWnd, &Ps);
font = CreateFont(90,0,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Adolescence");
SelectObject(hDC, font);
TextOut(hDC, 22, 0, "Dog Simulator 2", 15);
DeleteObject(font);
font = CreateFont(18,0,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Arial");
SelectObject(hDC, font);
TextOut(hDC, 13, 115, "Welcome to Dog Simulator 2 the sequel to Dog Simulator 1 from Kazalio Studios.", 78);
TextOut(hDC, 13, 135, "There are a few differences between dog Simulator 1 and Dog Simulator 2, the ", 77);
TextOut(hDC, 13, 155, "main one being that Dog Simulator 2 is now in a window and has fonts and ",72);
TextOut(hDC, 13, 175, "graphics to make it look better. There are also more things to do with your", 75);
TextOut(hDC, 13, 195, "dog.", 4);
DeleteObject(font);
EndPaint(hWnd, &Ps);
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
void startscrn (HWND hWnd, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT Ps;
HFONT font;
hDC = GetDC (GetParent((HWND) lParam));
Rectangle (hDC, 0, 0, 600, 460);
font = CreateFont(90,0,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Adolescence");
SelectObject(hDC, font);
TextOut(hDC, 22, 0, "Dog Simulator 2", 15);
DeleteObject(font);
font = CreateFont(18,0,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Arial");
SelectObject(hDC, font);
TextOut(hDC, 13, 115, "First you must ghhfg a name for your dog.", 42);
TextOut(hDC, 13, 135, "Names:", 6);
DeleteObject(font);
EndPaint(hWnd, &Ps);
}
void credits(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT Ps;
HFONT font;
hDC = GetDC (GetParent((HWND) lParam));
Rectangle (hDC, 0, 0, 600, 460);
hDC = GetDC (GetParent((HWND) lParam));
font = CreateFont(90,0,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Adolescence");
SelectObject(hDC, font);
TextOut(hDC, 22, 0, "Dog Simulator 2", 15);
font = CreateFont(18, 0, 0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Arial");
SelectObject(hDC, font);
TextOut(hDC, 13, 115, "Dog Simulator 1 and 2 was created by Kazalio Studios. The creators were:", 72);
TextOut(hDC, 13, 135, "Programming: Alex Pajak", 23);
TextOut(hDC, 13, 155, "Ideas/Design: Kasper Wilkosz", 28);
DeleteObject(font);
EndPaint(hWnd, &Ps);
hWnd = (GetParent((HWND) lParam));
HWND hBack;
hBack = CreateWindow ( "Button", "Back",
WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON,
10, 320, 140, 20,
hWnd, (HMENU) 4,
hInstGlobal, NULL );
switch(Msg)
{
case WM_COMMAND:
if (HIWORD(credits) == BN_CLICKED)
{
if(LOWORD(credits) == 4)
{
startscrn(hWnd, wParam, lParam);
UpdateWindow(hWnd);
}
}
}
}
void dogname(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT Ps;
HFONT font;
hDC = GetDC (GetParent((HWND) lParam));
Rectangle (hDC, 0, 0, 600, 460);
font = CreateFont(90,0,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Adolescence");
SelectObject(hDC, font);
TextOut(hDC, 22, 0, "Dog Simulator 2", 15);
DeleteObject(font);
font = CreateFont(18,0,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Arial");
SelectObject(hDC, font);
TextOut(hDC, 13, 115, "First you must choose a name for your dog.", 42);
TextOut(hDC, 13, 135, "Name:", 5);
DeleteObject(font);
EndPaint(hWnd, &Ps);
}