Oh really, they can't program... If you are such a great programmer explain this code:
#define WIN32_LEAN_AND_MEAN
//includes
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <math.h>
#include <mmsystem.h>
#include <iostream>
#include <stdlib.h>
#include "resource.h"
using namespace std;
//defines
#define WINDOW_CLASS_NAME "WINCLASS1"
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
//globals
HINSTANCE hinstance_app;
char buffer[80];
int green = RGB(0,255,0);
//void drawing(void);
//functions
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
RECT rect;
switch(msg)
{
case WM_CREATE:
{
PlaySound(MAKEINTRESOURCE(IDR_WAVE1), hinstance_app, SND_RESOURCE|SND_SYNC);
PlaySound(MAKEINTRESOURCE(IDR_WAVE2), hinstance_app, SND_RESOURCE|SND_ASYNC|SND_LOOP);
return(0);
}break;
case WM_COMMAND:
{
switch(LOWORD(wparam))
{
case ID_FILE_OPEN106:
{
}break;
case ID_FILE_CLOSE107:
{
}break;
case ID_FILE_SAVE108:
{
}break;
case ID_FILE_EXIT:
{
int result = MessageBox(hwnd,"Are you sure you want to quit?","Quit Message",MB_YESNO | MB_ICONQUESTION);
if(result == IDYES)
{
PostQuitMessage(0);
}
else
return(0);
}break;
case ID_HELP_ABOUT:
{
MessageBox(hwnd, "Look at my cool Project","About",MB_OK | MB_ICONEXCLAMATION);
}break;
case ID_PLAYSOUND_PLAYBEAM:
{
PlaySound(MAKEINTRESOURCE(IDR_WAVE3), hinstance_app, SND_RESOURCE | SND_ASYNC);
}break;
case ID_PLAYSOUND_PLAYTELEPORT:
{
PlaySound(MAKEINTRESOURCE(IDR_WAVE4), hinstance_app, SND_RESOURCE | SND_ASYNC);
}break;
case ID_FUNOPTIONS_CHANGEBACKGROUNDCOLOR120:
{
hdc = GetDC(hwnd);
SetBkColor(hdc,RGB(rand()%255,rand()%255,rand()%255));
ReleaseDC(hwnd,hdc);
}break;
default:break;
}
}
case WM_PAINT:
{
InvalidateRect(hwnd,NULL,FALSE);
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
}break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
}break;
case WM_CLOSE:
{
int result = MessageBox(hwnd,"Are you sure you want to quit?","Quit Message",MB_YESNO | MB_ICONQUESTION);
if(result == IDYES)
{
return(DefWindowProc(hwnd,msg,wparam,lparam));
}
else
return(0);
}break;
/*case WM_SIZE:
{
int width = LOWORD(lparam);
int height = HIWORD(lparam);
hdc = GetDC(hwnd);
SetTextColor(hdc, RGB(0,255,0));
SetBkColor(hdc,RGB(0,0,0));
SetBkMode(hdc,OPAQUE);
sprintf(buffer,"WM_SIZE called - New Size = (%d,%d)",width,height);
TextOut(hdc,0,0,buffer,strlen(buffer));
ReleaseDC(hwnd,hdc);
}break;*/
/*case WM_MOVE:
{
int xpos = LOWORD(lparam);
int ypos = HIWORD(wparam);
hdc = GetDC(hwnd);
SetTextColor(hdc,RGB(0,0,255));
SetBkColor(hdc,RGB(255,0,0));
SetBkMode(hdc,OPAQUE);
sprintf(buffer,"WM_MOVE Called - New Position = (%d,%d)",xpos,ypos);
TextOut(hdc,100,100,buffer,strlen(buffer));
ReleaseDC(hwnd,hdc);
}break;
case WM_KEYDOWN:
{
int virtual_code = (int)wparam;
int key_state = (int)lparam;
hdc = GetDC(hwnd);
SetTextColor(hdc, RGB(0,255,0));
SetBkColor(hdc,RGB(0,0,0));
SetBkMode(hdc,OPAQUE);
sprintf(buffer,"WM_CHAR: Character = %c ", virtual_code);
TextOut(hdc,200,200,buffer,strlen(buffer));
sprintf(buffer,"Key State = 0X%X ",key_state);
TextOut(hdc,200,216,buffer,strlen(buffer));
ReleaseDC(hwnd,hdc);
}break;
case WM_MOUSEMOVE:
{
int mouse_x = (int)LOWORD(lparam);
int mouse_y = (int)HIWORD(lparam);
int buttons = (int)wparam;
hdc = GetDC(hwnd);
SetTextColor(hdc,RGB(0,255,0));
SetBkColor(hdc,RGB(0,0,0));
SetBkMode(hdc,OPAQUE);
sprintf(buffer,"Mouse x position: = %d",mouse_x);
TextOut(hdc,0,80,buffer,strlen(buffer));
sprintf(buffer,"Mouse y position: = %d",mouse_y);
TextOut(hdc,0,96,buffer,strlen(buffer));
}break;*/
default:break;
}
return (DefWindowProc(hwnd, msg, wparam, lparam));
}
//winmain
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(hinstance, "IDI_ICON1");
winclass.hCursor = LoadCursor(hinstance, MAKEINTRESOURCE(IDC_CURSOR1));
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ICON1));
hinstance_app = hinstance;
if (!RegisterClassEx(&winclass))
return(0);
if (!(hwnd = CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"The GDI Project",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
400,400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
//hwndapp = hwnd;
int i;
HDC hdc = GetDC(hwnd);
while(TRUE)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
/*SetTextColor(hdc,green);
SetBkColor(hdc,RGB(0,0,0));
SetBkMode(hdc,OPAQUE);
sprintf(buffer,"Up Arrow: = %d ",KEYDOWN(VK_UP));
TextOut(hdc,0,16,buffer,strlen(buffer));
sprintf(buffer,"Down Arrow: = %d ",KEYDOWN(VK_DOWN));
TextOut(hdc,0,32,buffer,strlen(buffer));
sprintf(buffer,"Right Arrow: = %d ",KEYDOWN(VK_RIGHT));
TextOut(hdc,0,48,buffer,strlen(buffer));
sprintf(buffer,"Left Arrow: = %d ",KEYDOWN(VK_LEFT));
TextOut(hdc,0,64,buffer,strlen(buffer));*/
HPEN blue_pen = CreatePen(PS_SOLID,1,RGB(0,0,255));
HBRUSH green_brush = CreateSolidBrush(RGB(0,255,0));
HBRUSH old_brush = (HBRUSH)SelectObject(hdc,green_brush);
HPEN old_pen = (HPEN)SelectObject(hdc,blue_pen);
MoveToEx(hdc,20,10,NULL);
LineTo(hdc,30,20);
LineTo(hdc,10,20);
LineTo(hdc,20,10);
Ellipse(hdc,100,100,200,200);
Rectangle(hdc,250,300,300,20);
SelectObject(hdc,old_pen);
SelectObject(hdc,green_brush);
DeleteObject(green_brush);
DeleteObject(blue_pen);
//drawing();
if(KEYDOWN(VK_ESCAPE))
{
SendMessage(hwnd,WM_CLOSE,0,0);
}
if(KEYDOWN(VK_DOWN))
{
HBRUSH random_brush = CreateSolidBrush(RGB(rand()%255,rand()%255,rand()%255));
HBRUSH old_random_brush = (HBRUSH)SelectObject(hdc,random_brush);
HPEN random_pen_dashed = CreatePen(PS_DASH,20,RGB(rand()%255,rand()%255,rand()%255));
HPEN old_random_pen = (HPEN)SelectObject(hdc,random_pen_dashed);
Ellipse(hdc,rand()%400,rand()%400,rand()%400,rand()%400);
SelectObject(hdc,old_random_brush);
SelectObject(hdc,old_random_pen);
DeleteObject(random_brush);
DeleteObject(random_pen_dashed);
}
}
ReleaseDC(hwnd,hdc);
return(msg.wParam);
}
/*void drawing(void)
{
HDC hdcapp;
hdcapp = GetDC(hwndapp);
HPEN blue_pen = CreatePen(PS_DASH,2,RGB(0,0,255));
HPEN old_pen = (HPEN)SelectObject(hdcapp,blue_pen);
MoveToEx(hdcapp,10,10,NULL);
LineTo(hdcapp,20,20);
ReleaseDC(hwndapp,hdcapp);
}*/
This is just some basic stuff