Code:
/* VeggieBurgerCook.c By KryptKat /
/* instructions.txt */
/*
1. If all else fails read the instructions.txt
2. Your new proggie was compiled with Borland C 5.5 Command Line Tools.
3. Your new proggie was designed to run on a Windows box.
4. Getting Started. The first time your proggie runs she may miss the litter box. This is normal. You will notice a "calculate" button. Below that you will see an edit box. Below that you will see two small entry boxes. This is where you enter your pansize and the number of veggie burgers that you are going to cook. Your new proggie will assist you to determine just how long it will take. Most throughly cooked veggie burgers should take 20 minutes but yours for some strange reason only takes five minutes on each side. DISCLAIMER: If they <your veggie burgers> are suvearly under cooked it is not meow fault!
5. When comfortable with your new proggies opperation you may notice that the numbers you entered remain which will let you change or keep the numbers to do another calculation. Just hit the button again to reset. When "calculate" is pressed again your new calculations will appear.
6. Feeding your new proggie. Do not try to feed your new proggie with the veggie burgers. There is special proggie food for growing proggies <veggie proggie food>. Milk is good for your new proggie.
7. Tucking your new proggie in for the night. Most proggies enjoy a good night sleep. When you are ready for your proggie to go to sleep press the red "x" and your proggie will fall asleep quickly.
8. Remember to care for your new proggie every day./*
/* VeggieBurgerCook.c By KryptKat */
#include<stdio.h>
#include<windows.h>
#define MIN WM_USER + 1
enum {CLIENT_Button_Calculate = MIN};
#define frytime 10.0
float fryBurgers(float panSize, float numHamburgers)
{
float totaltime;
float cooktime;
cooktime = numHamburgers * frytime;
totaltime = cooktime / panSize;
return totaltime;
}
LRESULT APIENTRY ClientProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
HINSTANCE g_hInst;
/* form handles */
HWND Button_Calculate , Client_Edit_PanSize , Client_Edit_Burgers;
HWND Client_Edit_Message;
HWND hClient;
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR line, int CmdShow)
{
HFONT hDefaultFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
/* Main Form: */
WNDCLASS Window;
HWND hwnd;
MSG Msg;
Window.cbClsExtra = 0;
Window.cbWndExtra = 0;
Window.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
Window.hInstance = hInst;
Window.hIcon = NULL;
Window.hCursor = LoadCursor(NULL, IDC_ARROW);
Window.lpfnWndProc = (WNDPROC)ClientProc;
Window.lpszClassName = "Client";
Window.lpszMenuName = NULL;
Window.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&Window);
/* Create the Forms: */
hClient = CreateWindow("Client",
"VeggieBurgerCook",
WS_OVERLAPPED | WS_SYSMENU,
150,
150,
220,
240,
0,
0,
hInst,
0);
/* show form: */
ShowWindow(hClient, SW_SHOW);
UpdateWindow(hClient);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
if (!TranslateMDISysAccel(hClient, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
}
LRESULT APIENTRY ClientProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
float panSize;
float numHamburgers;
float totaltime;
char cookresult[200];
char Buffer[50];
HFONT hDefaultFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
switch(Msg)
{
case WM_CREATE:
{
Button_Calculate = CreateWindowEx(WS_EX_STATICEDGE, "Button", "Calculate", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5, 5, 100, 25, hWnd, (HMENU)CLIENT_Button_Calculate, g_hInst, 0);
SendMessage(Button_Calculate, WM_SETFONT, (WPARAM)hDefaultFont, MAKELPARAM(FALSE, 0));
Client_Edit_PanSize = CreateWindowEx(WS_EX_STATICEDGE, "Edit", "pansize", WS_CHILD | WS_VISIBLE, 115, 160, 85, 15, hWnd, NULL, g_hInst, 0);
SendMessage(Client_Edit_PanSize, WM_SETFONT, (WPARAM)hDefaultFont, MAKELPARAM(FALSE, 0));
Client_Edit_Burgers = CreateWindowEx(WS_EX_STATICEDGE, "Edit", "Burgers", WS_CHILD | WS_VISIBLE, 115, 180, 85, 15, hWnd, NULL, g_hInst, 0);
SendMessage(Client_Edit_Burgers, WM_SETFONT, (WPARAM)hDefaultFont, MAKELPARAM(FALSE, 0));
Client_Edit_Message = CreateWindowEx(WS_EX_STATICEDGE, "Edit", "", WS_CHILD | WS_VISIBLE | ES_MULTILINE, 5, 35, 205, 100, hWnd, NULL, g_hInst, 0);
SendMessage(Client_Edit_Message, WM_SETFONT, (WPARAM)hDefaultFont, MAKELPARAM(FALSE, 0));
break;
}
case WM_COMMAND:
{
switch(HIWORD(wParam))
{
case BN_CLICKED:
{
switch(LOWORD(wParam))
{
case CLIENT_Button_Calculate:
{
EnableWindow(Button_Calculate, 0);
GetWindowText(Button_Calculate, Buffer, sizeof(Buffer));
if (strcmp(Buffer, "Calculate") == 0)
{
GetWindowText(Client_Edit_PanSize, Buffer, sizeof(Buffer));
panSize = atoi(Buffer);
GetWindowText(Client_Edit_Burgers, Buffer, sizeof(Buffer));
numHamburgers = atoi(Buffer);
totaltime = fryBurgers( panSize, numHamburgers);
if(panSize >= numHamburgers) totaltime = frytime ;
sprintf( cookresult , "To cook %f Veggie burgers on a grill that will let cook only %f at a time it will take %f minutes " , numHamburgers, panSize , totaltime );
SetWindowText(Client_Edit_Message , cookresult );
SetWindowText(Button_Calculate, "WantFliesWithDat?");
}
else
{
SetWindowText(Button_Calculate, "Calculate");
}
EnableWindow(Button_Calculate, 1);
break;
}
}
break;
}
}
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
default: return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}