//====== The Following Program will be used in Computer Graphics course.==========
//============ Designed by Mr. Xiake.610004 =====================
//========================== Sept. 4, 2001 ============================
#define NUM 1000 //You'd better to change it to 10, just test the effect
#define TWOPI (2 * 3.14159)
void line ( HWND hwnd , POINT ptbeg ,POINT ptend);
void floodfill4(int x,int y,COLORREF oldcolor);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT("Hello");
HWND hwnd ;
MSG msg;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ; // the address of a window procedure used for all
// windows based on the class WNDCLASS
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
//each window class is assigned a name, here is "Hello"
if (!RegisterClass (&wndclass))
{
MessageBox(NULL, TEXT("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0;
}
hwnd = CreateWindow(szAppName ,
// window class name which is assigned in WNDCLASS object wndclass
TEXT("The Hello Program"),
//window's caption (title name)
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, //initial x position
CW_USEDEFAULT, //initial y position
CW_USEDEFAULT, //initial x size
CW_USEDEFAULT, //initial y size
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd) ;
static int cxClient, cyClient ; //should be equal to cx and cy
static int min ,MouseDown, dx, dy;
COLORREF crColor;
static int i;
HBRUSH hBrush;
int top;
static POINT mouseb,moused ,ptb, ptd ,apt[2];
switch (message)
{
case WM_CREATE:
// here we can do some initialization jobs.
hdc = GetDC(hwnd); //get the client area the device context
//.... initialize device context attributes
ReleaseDC(hwnd, hdc) ;
return 0 ;
case WM_PAINT:
hdc =BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
case WM_KEYDOWN:
switch(wParam)
{
case VK_HOME:
break;
case VK_END:
break;
case VK_PRIOR:
MessageBox(hwnd, TEXT("PageUp key down"),TEXT("键盘"), MB_OK);
break;
case VK_NEXT:
MessageBox(hwnd, TEXT("PageDown key down"),TEXT("键盘"), MB_OK);
break ;
case VK_LEFT:
case VK_RIGHT:
case VK_UP:
case VK_DOWN:
MessageBox(hwnd, TEXT("Direction key down"),TEXT("键盘"), MB_OK);
break ;
case VK_DELETE:
MessageBox(hwnd, TEXT("Delete key down"),TEXT("键盘"), MB_OK);
break;
}
return 0;
case WM_CHAR:
switch (wParam)
{
case '\b':
MessageBox(hwnd, TEXT("Backspace key down"),TEXT("键盘"), MB_OK);
break;
case 'Q':
case 'q': //Esacpe key
SendMessage(hwnd, WM_CLOSE,0, 0);
}
return 0;
case WM_CLOSE:
if(IDYES == MessageBox(hwnd, TEXT("Do you want to exit?"),
TEXT("Exit Window Hint"),
MB_DEFBUTTON2 | MB_ICONQUESTION | MB_YESNO))
PostQuitMessage(0); //if click yes, then ready to quit the program
return 0; //else, don't quit the program