//mouse #include <windows.h> static struct node{char c[1];int flag;char singleclick[11];char doubleclick[11];} a[]={'a',0,"apple","aim" , 'b',0,"ball","baseball" , 'c',0,"cat","cattle" , 'd',0,"dog","doll" , 'e',0,"elephant","eagle" , 'f',0,"fat","fast" , 'g',0,"goat","gate" , 'h',0,"hello","hi" , 'i',0,"intel","iteration" , 'j',0,"joy","joystick" , 'k',0,"kite","kin" , 'l',0,"land","lemon" , 'm',0,"mother","merit" , 'n',0,"nurd","nectar" , 'o',0,"oath","oak" , 'p',0,"pet","palindrome" , 'q',0,"queue","quit" , 'r',0,"right","red" , 's',0,"sit","sale" , 't',0,"tall","tale" , 'u',0,"umbrella","unit" , 'v',0,"victory","village" , 'w',0,"wall","well" , 'x',0,"xavier","xerox" , 'y',0,"yet","yak" , 'z',0,"zebra","zenith"}; lresult callback wndproc (hwnd, uint, wparam, lparam) ; winapi winmain (hinstance hinstance, hinstance hprevinstance,pstr szcmdline, int icmdshow) { static tchar szappname[] = text ("hellowin") ; hwnd hwnd ; msg msg ; wndclass wndclass ; wndclass.style = cs_hredraw | cs_vredraw | cs_dblclks; wndclass.lpfnwndproc = wndproc ; 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 ; if (!registerclass (&wndclass)) { messagebox (null, text ("this program requires windows nt!"),szappname, mb_iconerror) ; return 0 ; } hwnd = createwindow (szappname, // window class name text ("the hello program"), // window caption ws_overlappedwindow, // window style cw_usedefault, // initial x position cw_usedefault, // initial y position cw_usedefault, // initial x size cw_usedefault, // initial y size null, // parent window handle null, // window menu handle hinstance, // program instance handle null) ; // creation parameters showwindow (hwnd, icmdshow) ; updatewindow (hwnd) ; while (getmessage (&msg, null, 0, 0)) { translatemessage (&msg) ;
dispatchmessage (&msg) ; } return msg.wparam ; } lresult callback wndproc (hwnd hwnd, uint message, wparam wparam, lparam lparam) { hdc hdc ; paintstruct ps ; rect rect ; static int cxclient,cyclient; int y; switch (message) { case wm_size: cxclient = loword (lparam) ; cyclient = hiword (lparam) ; return 0; case wm_paint: hdc = beginpaint (hwnd, &ps) ; getclientrect (hwnd, &rect) ; //drawtext (hdc, text ("hello, windows 98!"), -1, &rect,dt_singleline | dt_center | dt_vcenter) ; endpaint (hwnd, &ps) ; return 0 ; case wm_lbuttondown: y=hiword(lparam); hdc=getdc(hwnd); if(a[y/(cyclient/26)].flag==0) { textout(hdc,50,y-y%(cyclient/26),a[y/(cyclient/26)].c,1); textout(hdc,90,y-y%(cyclient/26),a[y/(cyclient/26)].singleclick,wsprintf (a[y/(cyclient/26)].singleclick ,text (a[y/(cyclient/26)].singleclick))); a[y/(cyclient/26)].flag=1; } else { textout(hdc,50,y-y%(cyclient/26)," ",2); textout(hdc,90,y-y%(cyclient/26)," ",20); a[y/(cyclient/26)].flag=0; } releasedc(hwnd,hdc); return 0 ; case wm_lbuttondblclk: y=hiword(lparam); hdc=getdc(hwnd); if(a[y/(cyclient/26)].flag==0) { textout(hdc,50,y-y%(cyclient/26),a[y/(cyclient/26)].c,1); textout(hdc,90,y-y%(cyclient/26),a[y/(cyclient/26)].doubleclick,wsprintf (a[y/(cyclient/26)].doubleclick ,text (a[y/(cyclient/26)].doubleclick))); a[y/(cyclient/26)].flag=1;
} else { textout(hdc,50,y-y%(cyclient/26)," textout(hdc,90,y-y%(cyclient/26)," a[y/(cyclient/26)].flag=0;
",2);
} releasedc(hwnd,hdc); return 0 ; case wm_destroy: postquitmessage (0) ; return 0 ; } return defwindowproc (hwnd, message, wparam, lparam) ; }
",20);