#include "stdafx.h"
#include "resource.h"
#pragma comment(lib,"winmm.lib")
#include"mmsystem.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];
TCHAR sd[]="此软件由胡赵胜所做版权所有翻版必究" ;
char ss[]="";
int l=0,jj=0,z,lo=0;
char ee[]="hzs125";
TCHAR sd1[]="put your names please !"; // The title bar text
int s[20][20];
int c=0,h,k=0,u=0,add=0,o=0,p=0;
char f[]="";
char t[]="";
LPSYSTEMTIME lp;
HDC hdcem;
HBITMAP hbm;
BITMAP bm;
HWND hWnd,hchild,hchild1,hchild2,hchild3,hchild4,hchild5,hchild6,hchild7,hchild8,hchild9;
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
void init();
void n();
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_T, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_T);
hbm=LoadBitmap(hInstance,"l");
GetObject(hbm,sizeof(BITMAP),(LPVOID)&bm);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASS wcex;
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_T);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_T;
wcex.lpszClassName = szWindowClass;
return RegisterClass(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent,i,j;
DWORD x,y;
PAINTSTRUCT ps;
HDC hdc;
HBRUSH hb,hb1,hb2;
HPEN hp;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
switch (message)
{
case WM_CREATE:
hdc=GetDC(hWnd);
hdcem=CreateCompatibleDC(hdc);
ReleaseDC(hWnd,hdc);
hchild= CreateWindow("EDIT", NULL, WS_CHILD |WS_BORDER |ES_LEFT |ES_READONLY,
500, 200, 80,20, hWnd, (HMENU)IDE_RE, hInst, NULL);
SetWindowText(hchild,"0");
hchild1= CreateWindow("EDIT", NULL, WS_CHILD |WS_BORDER |ES_LEFT |ES_READONLY,
590, 200, 80,20, hWnd, (HMENU)IDE_RE1, hInst, NULL);
SetWindowText(hchild1,"0");
hchild2= CreateWindow("EDIT", NULL, WS_CHILD |WS_BORDER |ES_LEFT,
500, 160, 80,20, hWnd, (HMENU)IDE_RE2, hInst, NULL);
SetWindowText(hchild1,"0");
hchild3= CreateWindow("EDIT", NULL, WS_CHILD |WS_BORDER |ES_LEFT,
590, 160, 80,20, hWnd, (HMENU)IDE_RE3, hInst, NULL);
SetWindowText(hchild1,"0");
hchild4= CreateWindow("BUTTON", "确定", WS_CHILD |WS_BORDER |BS_PUSHBUTTON,
680, 160, 80,40, hWnd, (HMENU)IDB_RE4, hInst, NULL);
hchild5= CreateWindow("BUTTON", "退棋", WS_CHILD |WS_BORDER |BS_PUSHBUTTON,
600, 250, 90,30, hWnd, (HMENU)IDB_RE5, hInst, NULL);
hchild6= CreateWindow("BUTTON", "CANCER", WS_CHILD |WS_BORDER |BS_PUSHBUTTON,
500, 250, 90,30, hWnd, (HMENU)IDB_RE6, hInst, NULL);
hchild7= CreateWindow("EDIT", NULL, WS_CHILD |WS_VISIBLE|WS_BORDER |ES_LEFT|ES_PASSWORD,
500, 50, 80,20, hWnd, (HMENU)IDE_RE4, hInst, NULL);
hchild8= CreateWindow("BUTTON", "确定", WS_CHILD |WS_VISIBLE|WS_BORDER |BS_PUSHBUTTON,
500, 160, 80,25, hWnd, (HMENU)IDB_RE7, hInst, NULL);
hchild9= CreateWindow("EDIT", NULL, WS_CHILD |WS_BORDER |ES_LEFT|WS_VISIBLE|ES_READONLY,
100, 200, 400,80, hWnd, (HMENU)IDE_RE5, hInst, NULL);
SetWindowText(hchild9,"THE soft is made by hzs and welcome to my soft ");
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (LOWORD(wParam))
{
case IDB_RE4:
add=1;
SendMessage(hchild2,EM_SETREADONLY,1,0);
SendMessage(hchild3,EM_SETREADONLY,1,0);
break;
case IDB_RE5:
s[o][p]=0;
MessageBeep(10000);
if(c==1)
{
c=0;
}
else if(c==0)
{
c=1;
}
InvalidateRect(hWnd,NULL,1);
break;
case IDB_RE6:
DestroyWindow(hWnd);
PlaySound("SystemStart",NULL,SND_ALIAS|SND_SYNC);
break;
case IDB_RE7:
GetWindowText(hchild7,ss,9);
for(z=0;z<=5;z++)
{
if(ss[z]==ee[z])
{
jj++;
}
}
if(lo==3)
{
MessageBeep(1000);
MessageBox(hWnd,"you enter the worng password for 4 times!the soft will end!","PASS",MB_OK);
DestroyWindow(hWnd);
}
else if(jj==6)
{
l=1;
InvalidateRect(hWnd,NULL,1);
ShowWindow(hchild,SW_SHOW);
ShowWindow(hchild1,SW_SHOW);
ShowWindow(hchild2,SW_SHOW);
ShowWindow(hchild3,SW_SHOW);
ShowWindow(hchild4,SW_SHOW);
ShowWindow(hchild5,SW_SHOW);
ShowWindow(hchild6,SW_SHOW);
ShowWindow(hchild7,SW_HIDE);
ShowWindow(hchild8,SW_HIDE);
ShowWindow(hchild9,SW_HIDE);
}
else if(jj!=6)
{
lo++;
MessageBox(hWnd,"you enter the worng password!","PASS",MB_OK);
jj=0;
}
}
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_LBUTTONDOWN:
x=LOWORD(lParam);
y=HIWORD(lParam);
if(add==1)
{
for (i=0;i<=19;i++)
{
for (j=0;j<=19;j++)
{
if(c==0&&((x-i*20)*(x-i*20)+(y-j*20)*(y-j*20))<=25&&s[i][j]==0)
{
s[i][j]=-4;
c=1;
o=i;p=j;
InvalidateRect(hWnd,NULL,0);
break;
}
else if (c==1&&((x-i*20)*(x-i*20)+(y-j*20)*(y-j*20))<=25&&s[i][j]==0)
{
s[i][j]=1;
c=0;o=i;p=j;
InvalidateRect(hWnd,NULL,0);
break;
}
}
}
}
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
RECT rt;
SelectObject(hdcem,hbm);
BitBlt(hdc,100,200,bm.bmWidth,bm.bmHeight,hdc