Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 109.32 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. //WHATCLR
  4.  
  5. //#include<Windows.h>
  6. //#define ID_TIMER 1
  7. //
  8. //void FindWindowSize(int *, int*);
  9. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  10. //
  11. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  12. //{
  13. // static TCHAR szAppName[] = TEXT("WhatClr");
  14. // HWND hwnd;
  15. // int cxWindow, cyWindow;
  16. // MSG msg;
  17. // WNDCLASS wndclass;
  18. //
  19. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  20. // wndclass.lpfnWndProc = WndProc;
  21. // wndclass.cbClsExtra = 0;
  22. // wndclass.cbWndExtra = 0;
  23. // wndclass.hInstance = hInstance;
  24. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  25. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  26. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  27. // wndclass.lpszMenuName = NULL;
  28. // wndclass.lpszClassName = szAppName;
  29. //
  30. // if (!RegisterClass(&wndclass))
  31. // {
  32. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  33. // return 0;
  34. // }
  35. //
  36. // FindWindowSize(&cxWindow, &cyWindow);
  37. // hwnd = CreateWindow(szAppName, TEXT("What Color"), WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_BORDER, CW_USEDEFAULT, CW_USEDEFAULT, cxWindow, cyWindow, NULL, NULL, hInstance, NULL);
  38. // ShowWindow(hwnd, iCmdShow);
  39. // UpdateWindow(hwnd);
  40. //
  41. // while (GetMessage(&msg, NULL, 0, 0))
  42. // {
  43. // TranslateMessage(&msg);
  44. // DispatchMessage(&msg);
  45. // }
  46. // return msg.wParam;
  47. //
  48. //}
  49. //
  50. //void FindWindowSize(int * pcxWindow, int * pcyWindow)
  51. //{
  52. // HDC hdcScreen;
  53. // TEXTMETRIC tm;
  54. //
  55. // hdcScreen = CreateIC(TEXT("DISPLAY"), NULL, NULL, NULL);
  56. // GetTextMetrics(hdcScreen, &tm);
  57. // DeleteDC(hdcScreen);
  58. // * pcxWindow = 2 * GetSystemMetrics(SM_CXBORDER) + 12 * tm.tmAveCharWidth;
  59. //
  60. // * pcyWindow = 2 * GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYCAPTION) + 2 * tm.tmHeight;
  61. //
  62. //}
  63. //
  64. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  65. //{
  66. // static COLORREF cr, crLast;
  67. // static HDC hdcScreen;
  68. // HDC hdc;
  69. // PAINTSTRUCT ps;
  70. // POINT pt;
  71. // RECT rc;
  72. // TCHAR szBuffer[16];
  73. //
  74. // switch (message)
  75. // {
  76. // case WM_CREATE:
  77. // hdcScreen = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
  78. // SetTimer(hwnd, ID_TIMER, 100, NULL);
  79. // return 0;
  80. //
  81. // case WM_TIMER:
  82. // GetCursorPos(&pt);
  83. // cr = GetPixel(hdcScreen, pt.x, pt.y);
  84. // SetPixel(hdcScreen, pt.x, pt.y, 0);
  85. //
  86. // if (cr != crLast)
  87. // {
  88. // crLast = cr;
  89. // InvalidateRect(hwnd, NULL, FALSE);
  90. // }
  91. // return 0;
  92. //
  93. // case WM_PAINT:
  94. // hdc = BeginPaint(hwnd, &ps);
  95. // GetClientRect(hwnd, &rc);
  96. // wsprintf(szBuffer, TEXT(" %02X %02X %02x "), GetRValue(cr), GetGValue(cr), GetBValue(cr));
  97. // DrawText(hdc, szBuffer, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  98. // EndPaint(hwnd, &ps);
  99. // return 0;
  100. //
  101. // case WM_DESTROY:
  102. // DeleteDC(hdcScreen);
  103. // KillTimer(hwnd, ID_TIMER);
  104. // PostQuitMessage(0);
  105. // return 0;
  106. //
  107. // }
  108. //
  109. // return DefWindowProc(hwnd, message, wParam, lParam);
  110. //
  111. //}
  112.  
  113.  
  114. //CLOCK
  115.  
  116. //#include<Windows.h>
  117. //#include<math.h>
  118. //
  119. //#define ID_TIMER 1
  120. //#define TWOPI (2 * 3.14159)
  121. //
  122. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  123. //
  124. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  125. //{
  126. // static TCHAR szAppName[] = TEXT("Clock");
  127. // HWND hwnd;
  128. // MSG msg;
  129. // WNDCLASS wndclass;
  130. //
  131. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  132. // wndclass.lpfnWndProc = WndProc;
  133. // wndclass.cbClsExtra = 0;
  134. // wndclass.cbWndExtra = 0;
  135. // wndclass.hInstance = hInstance;
  136. // wndclass.hIcon = NULL;
  137. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  138. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  139. // wndclass.lpszMenuName = NULL;
  140. // wndclass.lpszClassName = szAppName;
  141. //
  142. // if (!RegisterClass(&wndclass))
  143. // {
  144. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  145. // return 0;
  146. // }
  147. //
  148. // hwnd = CreateWindow(szAppName, TEXT("Analog Clock"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  149. // ShowWindow(hwnd, iCmdShow);
  150. // UpdateWindow(hwnd);
  151. //
  152. // while (GetMessage(&msg, NULL, 0, 0))
  153. // {
  154. // TranslateMessage(&msg);
  155. // DispatchMessage(&msg);
  156. // }
  157. // return msg.wParam;
  158. //
  159. //}
  160. //
  161. //void SetIsotropic(HDC hdc, int cxClient, int cyClient)
  162. //{
  163. // SetMapMode(hdc, MM_ISOTROPIC);
  164. // SetWindowExtEx(hdc, 1000, 1000, NULL);
  165. // SetViewportExtEx(hdc, cxClient / 2, -cyClient / 2, NULL);
  166. // SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);
  167. //
  168. //}
  169. //
  170. //void RotatePoint(POINT pt[], int iNum, int iAngle)
  171. //{
  172. // int i;
  173. // POINT ptTemp;
  174. // for (i = 0; i < iNum; i++)
  175. // {
  176. // ptTemp.x = (int)(pt[i].x * cos(TWOPI * iAngle / 360) +
  177. // pt[i].y * sin(TWOPI * iAngle / 360));
  178. //
  179. // ptTemp.y = (int)(pt[i].y * cos(TWOPI * iAngle / 360) -
  180. // pt[i].x * sin(TWOPI * iAngle / 360));
  181. //
  182. // pt[i] = ptTemp;
  183. // }
  184. //
  185. //}
  186. //
  187. //void DrawClock(HDC hdc)
  188. //{
  189. // int iAngle;
  190. // POINT pt[3];
  191. //
  192. // for (iAngle = 0; iAngle < 360; iAngle += 6)
  193. // {
  194. // pt[0].x = 0;
  195. // pt[0].y = 900;
  196. //
  197. // RotatePoint(pt, 1, iAngle);
  198. //
  199. // pt[2].x = pt[2].y = iAngle % 5 ? 33 : 100;
  200. //
  201. // pt[0].x -= pt[2].x / 2;
  202. // pt[0].y -= pt[2].y / 2;
  203. //
  204. // pt[1].x = pt[0].x + pt[2].x;
  205. // pt[1].y = pt[0].y + pt[2].y;
  206. //
  207. // SelectObject(hdc, GetStockObject(BLACK_BRUSH));
  208. // Ellipse(hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
  209. //
  210. // }
  211. //
  212. //}
  213. //
  214. //void DrawHands(HDC hdc, SYSTEMTIME * pst, BOOL fChange)
  215. //{
  216. // static POINT pt[3][5] = { 0, -150, 100, 0, 0, 600, -100, 0, 0, -150,
  217. // 0, -200, 50, 0, 0, 800, -50, 0, 0, -200,
  218. // 0, 0, 0, 0, 0, 0, 0, 0, 0, 800 };
  219. //
  220. // int i, iAngle[3];
  221. // POINT ptTemp[3][5];
  222. //
  223. // iAngle[0] = (pst->wHour * 30) % 360 + pst->wMinute / 2;
  224. // iAngle[1] = pst->wMinute * 6;
  225. // iAngle[2] = pst->wSecond * 6;
  226. //
  227. // memcpy(ptTemp, pt, sizeof(pt));
  228. //
  229. // for (i = fChange ? 0 : 2; i < 3; i++)
  230. // {
  231. // RotatePoint(ptTemp[i], 5, iAngle[i]);
  232. // Polyline(hdc, ptTemp[i], 5);
  233. // }
  234. //}
  235. //
  236. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  237. //{
  238. // static int cxClient, cyClient;
  239. // static SYSTEMTIME stPrevious;
  240. // BOOL fChange;
  241. // HDC hdc;
  242. // PAINTSTRUCT ps;
  243. // SYSTEMTIME st;
  244. //
  245. // switch (message)
  246. // {
  247. // case WM_CREATE:
  248. // SetTimer(hwnd, ID_TIMER, 1000, NULL);
  249. // GetLocalTime(&st);
  250. // stPrevious = st;
  251. // return 0;
  252. //
  253. // case WM_SIZE:
  254. // cxClient = LOWORD(lParam);
  255. // cyClient = HIWORD(lParam);
  256. // return 0;
  257. //
  258. // case WM_TIMER:
  259. // GetLocalTime(&st);
  260. // fChange = st.wHour != stPrevious.wHour || st.wMinute != stPrevious.wMinute;
  261. //
  262. // hdc = GetDC(hwnd);
  263. //
  264. // SetIsotropic(hdc, cxClient, cyClient);
  265. //
  266. // SelectObject(hdc, GetStockObject(WHITE_PEN));
  267. // DrawHands(hdc, &stPrevious, fChange);
  268. //
  269. // SelectObject(hdc, GetStockObject(BLACK_PEN));
  270. // DrawHands(hdc, &st, TRUE);
  271. //
  272. // ReleaseDC(hwnd, hdc);
  273. // stPrevious = st;
  274. // return 0;
  275. //
  276. // case WM_PAINT:
  277. // hdc = BeginPaint(hwnd, &ps);
  278. // SetIsotropic(hdc, cxClient, cyClient);
  279. // DrawClock(hdc);
  280. // DrawHands(hdc, &stPrevious, TRUE);
  281. // EndPaint(hwnd, &ps);
  282. // return 0;
  283. //
  284. // case WM_DESTROY:
  285. // KillTimer(hwnd, ID_TIMER);
  286. // PostQuitMessage(0);
  287. // return 0;
  288. //
  289. // }
  290. //
  291. // return DefWindowProc(hwnd, message, wParam, lParam);
  292. //
  293. //}
  294.  
  295. //DIGLOCK
  296.  
  297. //#include<Windows.h>
  298. //
  299. //#define ID_TIMER 1
  300. //
  301. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  302. //
  303. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  304. //{
  305. // static TCHAR szAppName[] = TEXT("DigClock");
  306. // HWND hwnd;
  307. // MSG msg;
  308. // WNDCLASS wndclass;
  309. //
  310. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  311. // wndclass.lpfnWndProc = WndProc;
  312. // wndclass.cbClsExtra = 0;
  313. // wndclass.cbWndExtra = 0;
  314. // wndclass.hInstance = hInstance;
  315. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  316. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  317. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  318. // wndclass.lpszMenuName = NULL;
  319. // wndclass.lpszClassName = szAppName;
  320. //
  321. // if (!RegisterClass(&wndclass))
  322. // {
  323. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  324. // return 0;
  325. // }
  326. //
  327. // hwnd = CreateWindow(szAppName, TEXT("DigitalClock"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  328. // ShowWindow(hwnd, iCmdShow);
  329. // UpdateWindow(hwnd);
  330. //
  331. // while (GetMessage(&msg, NULL, 0, 0))
  332. // {
  333. // TranslateMessage(&msg);
  334. // DispatchMessage(&msg);
  335. // }
  336. //
  337. // return msg.wParam;
  338. //
  339. //}
  340. //
  341. //void DisplayDigit(HDC hdc, int iNumber)
  342. //{
  343. // static BOOL fSeventSegment[10][7] = {
  344. // 1, 1, 1, 0, 1, 1, 1, // 0
  345. // 0, 0, 1, 0, 0, 1, 0, // 1
  346. // 1, 0, 1, 1, 1, 0, 1, // 2
  347. // 1, 0, 1, 1, 0, 1, 1, // 3
  348. // 0, 1, 1, 1, 0, 1, 0, // 4
  349. // 1, 1, 0, 1, 0, 1, 1, // 5
  350. // 1, 1, 0, 1, 1, 1, 1, // 6
  351. // 1, 0, 1, 0, 0, 1, 0, // 7
  352. // 1, 1, 1, 1, 1, 1, 1, // 8
  353. // 1, 1, 1, 1, 0, 1, 1 }; // 9
  354. //
  355. // static POINT ptSegment[7][6] = {
  356. // 7, 6, 11, 2, 31, 2, 35, 6, 31, 10, 11, 10,
  357. // 6, 7, 10, 11, 10, 31, 6, 35, 2, 31, 2, 11,
  358. // 36, 7, 40, 11, 40, 31, 36, 35, 32, 31, 32, 11,
  359. // 7, 36, 11, 32, 31, 32, 35, 36, 31, 40, 11, 40,
  360. // 6, 37, 10, 41, 10, 61, 6, 65, 2, 61, 2, 41,
  361. // 36, 37, 40, 41, 40, 61, 36, 65, 32, 61, 32, 41,
  362. // 7, 66, 11, 62, 31, 62, 35, 66, 31, 70, 11, 70 };
  363. //
  364. // int iSeg;
  365. //
  366. // for (iSeg = 0; iSeg < 7; iSeg++)
  367. // if (fSeventSegment[iNumber][iSeg])
  368. // Polygon(hdc, ptSegment[iSeg], 6);
  369. //}
  370. //
  371. //void DisplayTwoDigits(HDC hdc, int iNumber, BOOL fSuppress)
  372. //{
  373. // if (!fSuppress || (iNumber / 10 != 0)) DisplayDigit(hdc, iNumber / 10);
  374. // OffsetWindowOrgEx(hdc, -42, 0, NULL);
  375. // DisplayDigit(hdc, iNumber % 10);
  376. // OffsetWindowOrgEx(hdc, -42, 0, NULL);
  377. //
  378. //}
  379. //
  380. //void DisplayColon(HDC hdc)
  381. //{
  382. // POINT ptColon[2][4] = { 2, 21, 6, 17, 10, 21, 6, 25,
  383. // 2, 51, 6, 47, 10, 51, 6, 55 };
  384. //
  385. // Polygon(hdc, ptColon[0], 4);
  386. // Polygon(hdc, ptColon[1], 4);
  387. // OffsetWindowOrgEx(hdc, -12, 0, NULL);
  388. //
  389. //}
  390. //
  391. //void DisplayTime(HDC hdc, BOOL f24Hour, BOOL fSuppress)
  392. //{
  393. // SYSTEMTIME st;
  394. // GetLocalTime(&st);
  395. // if (f24Hour) DisplayTwoDigits(hdc, st.wHour, fSuppress);
  396. // else DisplayTwoDigits(hdc, (st.wHour %= 12) ? st.wHour : 12, fSuppress);
  397. // DisplayColon(hdc);
  398. // DisplayTwoDigits(hdc, st.wMinute, FALSE);
  399. // DisplayColon(hdc);
  400. // DisplayTwoDigits(hdc, st.wSecond, FALSE);
  401. //
  402. //}
  403. //
  404. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  405. //{
  406. // static BOOL f24Hour, fSuppress;
  407. // static HBRUSH hBrushRed;
  408. // static int cxClient, cyClient;
  409. // HDC hdc;
  410. // PAINTSTRUCT ps;
  411. // TCHAR szBuffer[2];
  412. //
  413. // switch (message)
  414. // {
  415. // case WM_CREATE:
  416. // hBrushRed = CreateSolidBrush(RGB(255, 0, 0));
  417. // SetTimer(hwnd, ID_TIMER, 1000, NULL);
  418. //
  419. // case WM_SETTINGCHANGE:
  420. // GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ITIME, szBuffer, 2);
  421. // f24Hour = (szBuffer[0] == '1');
  422. // GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ITLZERO, szBuffer, 2);
  423. // fSuppress = (szBuffer[0] == '0');
  424. // InvalidateRect(hwnd, NULL, TRUE);
  425. // return 0;
  426. //
  427. // case WM_SIZE:
  428. // cxClient = LOWORD(lParam);
  429. // cyClient = HIWORD(lParam);
  430. // return 0;
  431. //
  432. // case WM_TIMER:
  433. // InvalidateRect(hwnd, NULL, TRUE);
  434. // return 0;
  435. //
  436. // case WM_PAINT:
  437. // hdc = BeginPaint(hwnd, &ps);
  438. // SetMapMode(hdc, MM_ISOTROPIC);
  439. // SetWindowExtEx(hdc, 276, 72, NULL);
  440. // SetViewportExtEx(hdc, cxClient, cyClient, NULL);
  441. //
  442. // SetWindowOrgEx(hdc, 138, 36, NULL);
  443. // SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);
  444. // SelectObject(hdc, GetStockObject(NULL_PEN));
  445. // SelectObject(hdc, hBrushRed);
  446. //
  447. // DisplayTime(hdc, f24Hour, fSuppress);
  448. // EndPaint(hwnd, &ps);
  449. // return 0;
  450. //
  451. // case WM_DESTROY:
  452. // KillTimer(hwnd, ID_TIMER);
  453. // DeleteObject(hBrushRed);
  454. // PostQuitMessage(0);
  455. // return 0;
  456. //
  457. // }
  458. //
  459. // return DefWindowProc(hwnd, message, wParam, lParam);
  460. //
  461. //}
  462.  
  463.  
  464. //BEEPER2
  465.  
  466. //#include<Windows.h>
  467. //
  468. //#define ID_TIMER 1
  469. //
  470. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  471. //VOID CALLBACK TimerProc(HWND, UINT, UINT, DWORD);
  472. //
  473. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  474. //{
  475. // static TCHAR szAppName[] = TEXT("Beeper2");
  476. // HWND hwnd;
  477. // MSG msg;
  478. // WNDCLASS wndclass;
  479. //
  480. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  481. // wndclass.lpfnWndProc = WndProc;
  482. // wndclass.cbClsExtra = 0;
  483. // wndclass.cbWndExtra = 0;
  484. // wndclass.hInstance = hInstance;
  485. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  486. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  487. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  488. // wndclass.lpszMenuName = NULL;
  489. // wndclass.lpszClassName = szAppName;
  490. //
  491. // if (!RegisterClass(&wndclass))
  492. // {
  493. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  494. // return 0;
  495. // }
  496. //
  497. // hwnd = CreateWindow(szAppName, TEXT("Beeper1 Timer Demo"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  498. // ShowWindow(hwnd, iCmdShow);
  499. // UpdateWindow(hwnd);
  500. // while (GetMessage(&msg, NULL, 0, 0))
  501. // {
  502. // TranslateMessage(&msg);
  503. // DispatchMessage(&msg);
  504. // }
  505. // return msg.wParam;
  506. //
  507. //}
  508. //
  509. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  510. //{
  511. // switch (message)
  512. // {
  513. // case WM_CREATE:
  514. // SetTimer(hwnd, ID_TIMER, 1000, TimerProc);
  515. // return 0;
  516. //
  517. // case WM_DESTROY:
  518. // KillTimer(hwnd, ID_TIMER);
  519. // PostQuitMessage(0);
  520. // return 0;
  521. // }
  522. // return DefWindowProc(hwnd, message, wParam, lParam);
  523. //
  524. //}
  525. //
  526. //
  527. //VOID CALLBACK TimerProc(HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime)
  528. //{
  529. // static BOOL fFlipFlop = FALSE;
  530. // HBRUSH hBrush;
  531. // HDC hdc;
  532. // RECT rc;
  533. //
  534. // MessageBeep(-1);
  535. // fFlipFlop = !fFlipFlop;
  536. // GetClientRect(hwnd, &rc);
  537. //
  538. // hdc = GetDC(hwnd);
  539. // hBrush = CreateSolidBrush(fFlipFlop ? RGB(255, 0, 0) : RGB(0, 0, 255));
  540. //
  541. // FillRect(hdc, &rc, hBrush);
  542. // ReleaseDC(hwnd, hdc);
  543. // DeleteObject(hBrush);
  544. //
  545. //}
  546.  
  547.  
  548. //BEEPER1
  549.  
  550. //#include<Windows.h>
  551. //#define ID_TIMER 1
  552. //
  553. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  554. //
  555. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  556. //{
  557. // static TCHAR szAppName[] = TEXT("Beeper1");
  558. // HWND hwnd;
  559. // MSG msg;
  560. // WNDCLASS wndclass;
  561. //
  562. // wndclass.style = CS_HREDRAW || CS_VREDRAW;
  563. // wndclass.lpfnWndProc = WndProc;
  564. // wndclass.cbClsExtra = 0;
  565. // wndclass.cbWndExtra = 0;
  566. // wndclass.hInstance = hInstance;
  567. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  568. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  569. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  570. // wndclass.lpszMenuName = NULL;
  571. // wndclass.lpszClassName = szAppName;
  572. //
  573. // if (!RegisterClass(&wndclass))
  574. // {
  575. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  576. // return 0;
  577. // }
  578. //
  579. // hwnd = CreateWindow(szAppName, TEXT("Beeper1 Timer Demo"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  580. // ShowWindow(hwnd, iCmdShow);
  581. // UpdateWindow(hwnd);
  582. // while (GetMessage(&msg, NULL, 0, 0))
  583. // {
  584. // TranslateMessage(&msg);
  585. // DispatchMessage(&msg);
  586. // }
  587. // return msg.wParam;
  588. //
  589. //}
  590. //
  591. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  592. //{
  593. // static BOOL fFlipFlop = FALSE;
  594. // HBRUSH hBrush;
  595. // HDC hdc;
  596. // PAINTSTRUCT ps;
  597. // RECT rc;
  598. //
  599. // switch (message)
  600. // {
  601. // case WM_CREATE:
  602. // SetTimer(hwnd, ID_TIMER, 1000, NULL);
  603. // return 0;
  604. //
  605. // case WM_TIMER:
  606. // MessageBeep(-1);
  607. // fFlipFlop = !fFlipFlop;
  608. // InvalidateRect(hwnd, NULL, FALSE);
  609. // return 0;
  610. //
  611. // case WM_PAINT:
  612. // hdc = BeginPaint(hwnd, &ps);
  613. // GetClientRect(hwnd, &rc);
  614. // hBrush = CreateSolidBrush(fFlipFlop ? RGB(255, 0, 0) : RGB(0, 0, 255));
  615. // FillRect(hdc, &rc, hBrush);
  616. // EndPaint(hwnd, &ps);
  617. // DeleteObject(hBrush);
  618. // return 0;
  619. //
  620. // case WM_DESTROY:
  621. // KillTimer(hwnd, ID_TIMER);
  622. // PostQuitMessage(0);
  623. // return 0;
  624. // }
  625. //
  626. // return DefWindowProc(hwnd, message, wParam, lParam);
  627. //
  628. //}
  629.  
  630.  
  631. //SYSMETS
  632.  
  633. //#include<Windows.h>
  634. //#include "sysmets.h"
  635. //
  636. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  637. //
  638. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  639. //{
  640. // static TCHAR szAppName[] = TEXT("SysMets");
  641. // HWND hwnd;
  642. // MSG msg;
  643. // WNDCLASS wndclass;
  644. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  645. // wndclass.lpfnWndProc = WndProc;
  646. // wndclass.cbClsExtra = 0;
  647. // wndclass.cbWndExtra = 0;
  648. // wndclass.hInstance = hInstance;
  649. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  650. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  651. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  652. // wndclass.lpszMenuName = NULL;
  653. // wndclass.lpszClassName = szAppName;
  654. //
  655. // if (!RegisterClass(&wndclass))
  656. // {
  657. // MessageBox(NULL, TEXT("Program requires Windows NT!"),
  658. // szAppName, MB_ICONERROR);
  659. // return 0;
  660. // }
  661. // hwnd = CreateWindow(szAppName, TEXT("Get System Metrics"),
  662. // WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL,
  663. // CW_USEDEFAULT, CW_USEDEFAULT,
  664. // CW_USEDEFAULT, CW_USEDEFAULT,
  665. // NULL, NULL, hInstance, NULL);
  666. //
  667. // ShowWindow(hwnd, iCmdShow);
  668. // UpdateWindow(hwnd);
  669. // while (GetMessage(&msg, NULL, 0, 0))
  670. // {
  671. // TranslateMessage(&msg);
  672. // DispatchMessage(&msg);
  673. // }
  674. // return msg.wParam;
  675. //}
  676. //
  677. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  678. //{
  679. // static int cxChar, cxCaps, cyChar, cxClient, cyClient, iMaxWidth;
  680. // static int iDeltaPerLine, iAccumDelta;
  681. // int i, x, y, iVertPos, iHorzPos, iPaintBeg, iPaintEnd;
  682. // HDC hdc;
  683. // PAINTSTRUCT ps;
  684. // SCROLLINFO si;
  685. // TCHAR szBuffer[10];
  686. // TEXTMETRIC tm;
  687. // ULONG ulScrollLines;
  688. //
  689. // switch (message)
  690. // {
  691. // case WM_CREATE:
  692. // hdc = GetDC(hwnd);
  693. // GetTextMetrics(hdc, &tm);
  694. // cxChar = tm.tmAveCharWidth;
  695. // cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2)*cxChar / 2;
  696. // cyChar = tm.tmHeight + tm.tmExternalLeading;
  697. //
  698. // ReleaseDC(hwnd, hdc);
  699. // iMaxWidth = 40 * cxChar + 22 * cxCaps;
  700. //
  701. // case WM_SETTINGCHANGE:
  702. // SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ulScrollLines, 0);
  703. // if (ulScrollLines) iDeltaPerLine = WHEEL_DELTA / ulScrollLines;
  704. // else iDeltaPerLine = 0;
  705. // return 0;
  706. //
  707. // case WM_SIZE:
  708. // cxClient = LOWORD(lParam);
  709. // cyClient = HIWORD(lParam);
  710. //
  711. // si.cbSize = sizeof(si);
  712. // si.fMask = SIF_RANGE | SIF_PAGE;
  713. // si.nMin = 0;
  714. // si.nMax = NUMLINES - 1;
  715. // si.nPage = cyClient / cyChar;
  716. // SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
  717. //
  718. // si.cbSize = sizeof(si);
  719. // si.fMask = SIF_RANGE | SIF_PAGE;
  720. // si.nMin = 0;
  721. // si.nMax = 2 + iMaxWidth / cxChar;
  722. // si.nPage = cxClient / cxChar;
  723. // SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
  724. // return 0;
  725. //
  726. // case WM_VSCROLL:
  727. // si.cbSize = sizeof(si);
  728. // si.fMask = SIF_ALL;
  729. // GetScrollInfo(hwnd, SB_VERT, &si);
  730. // iVertPos = si.nPos;
  731. //
  732. // switch (LOWORD(wParam))
  733. // {
  734. // case SB_TOP:
  735. // si.nPos = si.nMin;
  736. // break;
  737. //
  738. // case SB_BOTTOM:
  739. // si.nPos = si.nMax;
  740. // break;
  741. //
  742. // case SB_LINEUP:
  743. // si.nPos -= 1;
  744. // break;
  745. //
  746. // case SB_LINEDOWN:
  747. // si.nPos += 1;
  748. // break;
  749. //
  750. // case SB_PAGEUP:
  751. // si.nPos -= si.nPage;
  752. // break;
  753. //
  754. // case SB_PAGEDOWN:
  755. // si.nPos += si.nPage;
  756. // break;
  757. //
  758. // case SB_THUMBTRACK:
  759. // si.nPos = si.nTrackPos;
  760. // break;
  761. //
  762. // default:
  763. // break;
  764. // }
  765. //
  766. // si.fMask = SIF_POS;
  767. // SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
  768. // GetScrollInfo(hwnd, SB_VERT, &si);
  769. // if (si.nPos != iVertPos)
  770. // {
  771. // ScrollWindow(hwnd, 0, cyChar * (iVertPos - si.nPos), NULL, NULL);
  772. // UpdateWindow(hwnd);
  773. // }
  774. // return 0;
  775. //
  776. // case WM_HSCROLL:
  777. // si.cbSize = sizeof(si);
  778. // si.fMask = SIF_ALL;
  779. //
  780. // GetScrollInfo(hwnd, SB_HORZ, &si);
  781. // iHorzPos = si.nPos;
  782. //
  783. // switch (LOWORD(wParam))
  784. // {
  785. // case SB_LINELEFT:
  786. // si.nPos -= 1;
  787. // break;
  788. //
  789. // case SB_LINERIGHT:
  790. // si.nPos += 1;
  791. // break;
  792. //
  793. // case SB_PAGELEFT:
  794. // si.nPos -= si.nPage;
  795. // break;
  796. //
  797. // case SB_PAGERIGHT:
  798. // si.nPos += si.nPage;
  799. // break;
  800. //
  801. // case SB_THUMBPOSITION:
  802. // si.nPos = si.nTrackPos;
  803. // break;
  804. //
  805. // default:
  806. // break;
  807. // }
  808. //
  809. // si.fMask = SIF_POS;
  810. // SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
  811. // GetScrollInfo(hwnd, SB_HORZ, &si);
  812. //
  813. // if (si.nPos != iHorzPos)
  814. // {
  815. // ScrollWindow(hwnd, cxChar * (iHorzPos - si.nPos), 0, NULL, NULL);
  816. // }
  817. // return 0;
  818. //
  819. // case WM_KEYDOWN:
  820. // switch (wParam)
  821. // {
  822. // case VK_HOME:
  823. // SendMessage(hwnd, WM_VSCROLL, SB_TOP, 0);
  824. // break;
  825. //
  826. // case VK_END:
  827. // SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, 0);
  828. // break;
  829. //
  830. // case VK_PRIOR:
  831. // SendMessage(hwnd, WM_VSCROLL, SB_PAGEUP, 0);
  832. // break;
  833. // case VK_NEXT:
  834. // SendMessage(hwnd, WM_VSCROLL, SB_PAGEDOWN, 0);
  835. // break;
  836. // case VK_UP:
  837. // SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0);
  838. // break;
  839. // case VK_DOWN:
  840. // SendMessage(hwnd, WM_VSCROLL, SB_LINEDOWN, 0);
  841. // break;
  842. // case VK_LEFT:
  843. // SendMessage(hwnd, WM_HSCROLL, SB_PAGEUP, 0);
  844. // break;
  845. // case VK_RIGHT:
  846. // SendMessage(hwnd, WM_HSCROLL, SB_PAGEDOWN, 0);
  847. // break;
  848. // }
  849. // return 0;
  850. //
  851. // case WM_MOUSEWHEEL:
  852. // if ((iDeltaPerLine == 0)) break;
  853. // iAccumDelta += (short)HIWORD(wParam);
  854. // while (iAccumDelta >= iDeltaPerLine)
  855. // {
  856. // SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0);
  857. // iAccumDelta -= iDeltaPerLine;
  858. // }
  859. //
  860. // while (iAccumDelta <= -iDeltaPerLine)
  861. // {
  862. // SendMessage(hwnd, WM_VSCROLL, SB_LINEDOWN, 0);
  863. // iAccumDelta += iDeltaPerLine;
  864. // }
  865. // return 0;
  866. //
  867. // case WM_PAINT:
  868. // hdc = BeginPaint(hwnd, &ps);
  869. // si.cbSize = sizeof(si);
  870. // si.fMask = SIF_POS;
  871. // GetScrollInfo(hwnd, SB_VERT, &si);
  872. // iVertPos = si.nPos;
  873. // GetScrollInfo(hwnd, SB_HORZ, &si);
  874. // iHorzPos = si.nPos;
  875. // iPaintBeg = max (0, iVertPos + ps.rcPaint.top / cyChar);
  876. // iPaintEnd = min (NUMLINES - 1, iVertPos + ps.rcPaint.bottom / cyChar);
  877. //
  878. // for (i = iPaintBeg; i <= iPaintEnd; i++)
  879. // {
  880. // x = cxChar * (1 - iHorzPos);
  881. // y = cyChar * (i - iVertPos);
  882. // TextOut(hdc, x, y,
  883. // sysmetrics[i].szLabel,
  884. // lstrlen(sysmetrics[i].szLabel));
  885. // TextOut(hdc, x + 22 * cxCaps, y,
  886. // sysmetrics[i].szDesc,
  887. // lstrlen(sysmetrics[i].szDesc));
  888. // SetTextAlign(hdc, TA_RIGHT | TA_TOP);
  889. // TextOut(hdc, x + 22 * cxCaps + 40 * cxChar, y, szBuffer,
  890. // wsprintf(szBuffer, TEXT("%5d"),
  891. // GetSystemMetrics(sysmetrics[i].iIndex)));
  892. // SetTextAlign(hdc, TA_LEFT | TA_TOP);
  893. // }
  894. // EndPaint(hwnd, &ps);
  895. // return 0;
  896. //
  897. // case WM_DESTROY:
  898. // PostQuitMessage(0);
  899. // return 0;
  900. // }
  901. // return DefWindowProc(hwnd, message, wParam, lParam);
  902. //}
  903.  
  904. //BLOCKOUT2
  905.  
  906. //#include<Windows.h>
  907. //
  908. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  909. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  910. //{
  911. // static TCHAR szAppName[] = TEXT("BlokOut2");
  912. // HWND hwnd;
  913. // MSG msg;
  914. // WNDCLASS wndclass;
  915. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  916. // wndclass.lpfnWndProc = WndProc;
  917. // wndclass.cbClsExtra = 0;
  918. // wndclass.cbWndExtra = 0;
  919. // wndclass.hInstance = hInstance;
  920. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  921. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  922. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  923. // wndclass.lpszMenuName = NULL;
  924. // wndclass.lpszClassName = szAppName;
  925. //
  926. // if (!RegisterClass(&wndclass))
  927. // {
  928. // MessageBox(NULL, TEXT("Program requires Windows NT!"),
  929. // szAppName, MB_ICONERROR);
  930. // return 0;
  931. // }
  932. // hwnd = CreateWindow(szAppName, TEXT("Mouse Button & Capture Demo"),
  933. // WS_OVERLAPPEDWINDOW,
  934. // CW_USEDEFAULT, CW_USEDEFAULT,
  935. // CW_USEDEFAULT, CW_USEDEFAULT,
  936. // NULL, NULL, hInstance, NULL);
  937. // ShowWindow(hwnd, iCmdShow);
  938. // UpdateWindow(hwnd);
  939. //
  940. // while (GetMessage(&msg, NULL, 0, 0))
  941. // {
  942. // TranslateMessage(&msg);
  943. // DispatchMessage(&msg);
  944. // }
  945. // return msg.wParam;
  946. //
  947. //}
  948. //
  949. //void DrawBoxOutline(HWND hwnd, POINT ptBeg, POINT ptEnd)
  950. //{
  951. // HDC hdc;
  952. // hdc = GetDC(hwnd);
  953. // SetROP2(hdc, R2_NOT);
  954. // SelectObject(hdc, GetStockObject(NULL_BRUSH));
  955. // Rectangle(hdc, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y);
  956. // ReleaseDC(hwnd, hdc);
  957. //}
  958. //
  959. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  960. //{
  961. // static BOOL fBlocking, fValidBox;
  962. // static POINT ptBeg, ptEnd, ptBoxBeg, ptBoxEnd;
  963. // HDC hdc;
  964. // PAINTSTRUCT ps;
  965. //
  966. // switch (message)
  967. // {
  968. // case WM_LBUTTONDOWN:
  969. // ptBeg.x = ptEnd.x = LOWORD(lParam);
  970. // ptBeg.y = ptEnd.y = HIWORD(lParam);
  971. //
  972. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  973. // SetCapture(hwnd);
  974. // SetCursor(LoadCursor(NULL, IDC_CROSS));
  975. //
  976. // fBlocking = TRUE;
  977. // return 0;
  978. //
  979. // case WM_MOUSEMOVE:
  980. // if (fBlocking)
  981. // {
  982. // SetCursor(LoadCursor(NULL, IDC_CROSS));
  983. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  984. // ptEnd.x = LOWORD(lParam);
  985. // ptEnd.y = HIWORD(lParam);
  986. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  987. // }
  988. // return 0;
  989. //
  990. // case WM_LBUTTONUP:
  991. // if (fBlocking)
  992. // {
  993. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  994. // ptBoxBeg = ptBeg;
  995. // ptBoxEnd.x = LOWORD(lParam);
  996. // ptBoxEnd.y = HIWORD(lParam);
  997. // ReleaseCapture();
  998. // SetCursor(LoadCursor(NULL, IDC_ARROW));
  999. // fBlocking = FALSE;
  1000. // fValidBox = TRUE;
  1001. // InvalidateRect(hwnd, NULL, TRUE);
  1002. //
  1003. // }
  1004. // return 0;
  1005. //
  1006. // case WM_CHAR:
  1007. // if (fBlocking & wParam == '\x1B')
  1008. // {
  1009. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  1010. // ReleaseCapture();
  1011. // SetCursor(LoadCursor(NULL, IDC_ARROW));
  1012. //
  1013. // fBlocking = FALSE;
  1014. // }
  1015. // return 0;
  1016. //
  1017. // case WM_PAINT:
  1018. // hdc = BeginPaint(hwnd, &ps);
  1019. // if (fValidBox)
  1020. // {
  1021. // SelectObject(hdc, GetStockObject(BLACK_BRUSH));
  1022. // Rectangle(hdc, ptBoxBeg.x, ptBoxBeg.y, ptBoxEnd.x, ptBoxEnd.y);
  1023. // }
  1024. //
  1025. // if (fBlocking)
  1026. // {
  1027. // SetROP2(hdc, R2_NOT);
  1028. // SelectObject(hdc, GetStockObject(NULL_BRUSH));
  1029. // Rectangle(hdc, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y);
  1030. // }
  1031. //
  1032. // EndPaint(hwnd, &ps);
  1033. // return 0;
  1034. //
  1035. // case WM_DESTROY:
  1036. // PostQuitMessage(0);
  1037. // return 0;
  1038. // }
  1039. //
  1040. // return DefWindowProc(hwnd, message, wParam, lParam);
  1041. //}
  1042.  
  1043. //BLOKOUT
  1044.  
  1045. //#include<Windows.h>
  1046. //
  1047. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  1048. //
  1049. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  1050. //{
  1051. // static TCHAR szAppName[] = TEXT("Blokout1");
  1052. // HWND hwnd;
  1053. // MSG msg;
  1054. // WNDCLASS wndclass;
  1055. //
  1056. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  1057. // wndclass.lpfnWndProc = WndProc;
  1058. // wndclass.cbClsExtra = 0;
  1059. // wndclass.cbWndExtra = 0;
  1060. // wndclass.hInstance = hInstance;
  1061. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  1062. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  1063. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  1064. // wndclass.lpszMenuName = NULL;
  1065. // wndclass.lpszClassName = szAppName;
  1066. //
  1067. // if (!RegisterClass(&wndclass))
  1068. // {
  1069. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  1070. // return 0;
  1071. // }
  1072. //
  1073. // hwnd = CreateWindow(szAppName, TEXT("Mouse Button Demo"),
  1074. // WS_OVERLAPPEDWINDOW,
  1075. // CW_USEDEFAULT, CW_USEDEFAULT,
  1076. // CW_USEDEFAULT, CW_USEDEFAULT,
  1077. // NULL, NULL, hInstance, NULL);
  1078. // ShowWindow(hwnd, iCmdShow);
  1079. // UpdateWindow(hwnd);
  1080. // while (GetMessage(&msg, NULL, 0, 0))
  1081. // {
  1082. // TranslateMessage(&msg);
  1083. // DispatchMessage(&msg);
  1084. // }
  1085. // return msg.wParam;
  1086. //
  1087. //}
  1088. //
  1089. //void DrawBoxOutline(HWND hwnd, POINT ptBeg, POINT ptEnd)
  1090. //{
  1091. // HDC hdc;
  1092. // hdc = GetDC(hwnd);
  1093. // SetROP2(hdc, R2_NOT);
  1094. // SelectObject(hdc, GetStockObject(NULL_BRUSH));
  1095. // Rectangle(hdc, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y);
  1096. // ReleaseDC(hwnd, hdc);
  1097. //
  1098. //}
  1099. //
  1100. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1101. //{
  1102. // static BOOL fBlocking, fValidBox;
  1103. // static POINT ptBeg, ptEnd, ptBoxBeg, ptBoxEnd;
  1104. // HDC hdc;
  1105. // PAINTSTRUCT ps;
  1106. //
  1107. // switch (message)
  1108. // {
  1109. // case WM_LBUTTONDOWN:
  1110. // ptBeg.x = ptEnd.x = LOWORD(lParam);
  1111. // ptBeg.y = ptEnd.y = HIWORD(lParam);
  1112. //
  1113. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  1114. // SetCursor(LoadCursor(NULL, IDC_CROSS));
  1115. // fBlocking = TRUE;
  1116. // return 0;
  1117. //
  1118. // case WM_MOUSEMOVE:
  1119. // if (fBlocking)
  1120. // {
  1121. // SetCursor(LoadCursor(NULL, IDC_CROSS));
  1122. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  1123. // ptEnd.x = LOWORD(lParam);
  1124. // ptEnd.y = HIWORD(lParam);
  1125. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  1126. // }
  1127. // return 0;
  1128. //
  1129. // case WM_LBUTTONUP:
  1130. // if (fBlocking)
  1131. // {
  1132. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  1133. //
  1134. // ptBoxBeg = ptBeg;
  1135. // ptBoxEnd.x = LOWORD(lParam);
  1136. // ptBoxEnd.y = HIWORD(lParam);
  1137. //
  1138. // SetCursor(LoadCursor(NULL, IDC_ARROW));
  1139. // fBlocking = FALSE;
  1140. // fValidBox = TRUE;
  1141. // InvalidateRect(hwnd, NULL, TRUE);
  1142. // }
  1143. // return 0;
  1144. //
  1145. // case WM_CHAR:
  1146. // if (fBlocking & wParam == '\x1B')
  1147. // {
  1148. // DrawBoxOutline(hwnd, ptBeg, ptEnd);
  1149. // SetCursor(LoadCursor(NULL, IDC_ARROW));
  1150. // fBlocking = FALSE;
  1151. // }
  1152. // return 0;
  1153. //
  1154. // case WM_PAINT:
  1155. // hdc = BeginPaint(hwnd, &ps);
  1156. // if (fValidBox)
  1157. // {
  1158. // SelectObject(hdc, GetStockObject(BLACK_BRUSH));
  1159. // Rectangle(hdc, ptBoxBeg.x, ptBoxBeg.y, ptBoxEnd.x, ptBoxEnd.y);
  1160. // }
  1161. //
  1162. // if (fBlocking)
  1163. // {
  1164. // SetROP2(hdc, R2_NOT);
  1165. // SelectObject(hdc, GetStockObject(NULL_BRUSH));
  1166. // Rectangle(hdc, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y);
  1167. // }
  1168. // EndPaint(hwnd, &ps);
  1169. // return 0;
  1170. //
  1171. // case WM_DESTROY:
  1172. // PostQuitMessage(0);
  1173. // return 0;
  1174. // }
  1175. //
  1176. // return DefWindowProc(hwnd, message, wParam, lParam);
  1177. //}
  1178.  
  1179.  
  1180. //CHECKER4
  1181.  
  1182. //#include<Windows.h>
  1183. //#define DIVISIONS 5
  1184. //
  1185. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  1186. //LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
  1187. //
  1188. //int idFocus = 0;
  1189. //TCHAR szChildClass[] = TEXT("Checker4_Child");
  1190. //
  1191. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  1192. //{
  1193. // static TCHAR szAppName[] = TEXT("Checker4");
  1194. // HWND hwnd;
  1195. // MSG msg;
  1196. // WNDCLASS wndclass;
  1197. //
  1198. // wndclass.style = CS_HREDRAW || CS_VREDRAW;
  1199. // wndclass.lpfnWndProc = WndProc;
  1200. // wndclass.cbClsExtra = 0;
  1201. // wndclass.cbWndExtra = 0;
  1202. // wndclass.hInstance = hInstance;
  1203. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  1204. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  1205. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  1206. // wndclass.lpszMenuName = NULL;
  1207. // wndclass.lpszClassName = szAppName;
  1208. //
  1209. // if (!RegisterClass(&wndclass))
  1210. // {
  1211. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  1212. // return 0;
  1213. // }
  1214. //
  1215. // wndclass.lpfnWndProc = ChildWndProc;
  1216. // wndclass.cbWndExtra = sizeof(long);
  1217. // wndclass.hIcon = NULL;
  1218. // wndclass.lpszClassName = szChildClass;
  1219. // RegisterClass(&wndclass);
  1220. //
  1221. // hwnd = CreateWindow(szAppName, TEXT("Checker4 Mouse Hit−Test Demo"),
  1222. // WS_OVERLAPPEDWINDOW,
  1223. // CW_USEDEFAULT, CW_USEDEFAULT,
  1224. // CW_USEDEFAULT, CW_USEDEFAULT,
  1225. // NULL, NULL, hInstance, NULL);
  1226. //
  1227. // ShowWindow(hwnd, iCmdShow);
  1228. // UpdateWindow(hwnd);
  1229. // while (GetMessage(&msg, NULL, 0, 0))
  1230. // {
  1231. // TranslateMessage(&msg);
  1232. // DispatchMessage(&msg);
  1233. // }
  1234. // return msg.wParam;
  1235. //
  1236. //}
  1237. //
  1238. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1239. //{
  1240. // static HWND hwndChild[DIVISIONS][DIVISIONS];
  1241. // int cxBlock, cyBlock, x, y;
  1242. // switch (message)
  1243. // {
  1244. // case WM_CREATE:
  1245. // for (x = 0; x < DIVISIONS; x++)
  1246. // {
  1247. // for (y = 0; y < DIVISIONS; y++)
  1248. // {
  1249. // hwndChild[x][y] = CreateWindow(szChildClass, NULL,
  1250. // WS_CHILDWINDOW | WS_VISIBLE,
  1251. // 0, 0, 0, 0,
  1252. // hwnd, (HMENU)(y << 8 | x),
  1253. // (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE),
  1254. // NULL);
  1255. // }
  1256. // }
  1257. // return 0;
  1258. //
  1259. // case WM_SIZE:
  1260. // cxBlock = LOWORD(lParam) / DIVISIONS;
  1261. // cyBlock = HIWORD(lParam) / DIVISIONS;
  1262. //
  1263. // for (x = 0; x < DIVISIONS; x++)
  1264. // {
  1265. // for (y = 0; y < DIVISIONS; y++)
  1266. // {
  1267. // MoveWindow(hwndChild[x][y], x*cxBlock, y*cyBlock, cxBlock, cyBlock, TRUE);
  1268. // }
  1269. // }
  1270. // return 0;
  1271. //
  1272. // case WM_LBUTTONDOWN:
  1273. // MessageBeep(0);
  1274. // return 0;
  1275. //
  1276. // case WM_SETFOCUS:
  1277. // SetFocus(GetDlgItem(hwnd, idFocus));
  1278. // return 0;
  1279. //
  1280. // case WM_KEYDOWN:
  1281. // x = idFocus & 0xFF;
  1282. // y = idFocus >> 8;
  1283. //
  1284. // switch (wParam)
  1285. // {
  1286. // case VK_UP: y--; break;
  1287. // case VK_DOWN: y++; break;
  1288. // case VK_LEFT: x--; break;
  1289. // case VK_RIGHT: x++; break;
  1290. // case VK_HOME: x = y = 0; break;
  1291. // case VK_END: x = y = DIVISIONS - 1; break;
  1292. // default: return 0;
  1293. // }
  1294. // x = (x + DIVISIONS) % DIVISIONS;
  1295. // y = (y + DIVISIONS) % DIVISIONS;
  1296. //
  1297. // idFocus = y << 8 | x;
  1298. // SetFocus(GetDlgItem(hwnd, idFocus));
  1299. // return 0;
  1300. //
  1301. // case WM_DESTROY:
  1302. // PostQuitMessage(0);
  1303. // return 0;
  1304. // }
  1305. //
  1306. // return DefWindowProc(hwnd, message, wParam, lParam);
  1307. //}
  1308. //
  1309. //LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1310. //{
  1311. // HDC hdc;
  1312. // PAINTSTRUCT ps;
  1313. // RECT rect;
  1314. //
  1315. // switch (message)
  1316. // {
  1317. // case WM_CREATE:
  1318. // SetWindowLong(hwnd, 0, 0);
  1319. // return 0;
  1320. //
  1321. // case WM_KEYDOWN:
  1322. // if (wParam != VK_RETURN && wParam != VK_SPACE)
  1323. // {
  1324. // SendMessage(GetParent(hwnd), message, wParam, lParam);
  1325. // return 0;
  1326. // }
  1327. //
  1328. // case WM_LBUTTONDOWN:
  1329. // SetWindowLong(hwnd, 0, 01 ^ GetWindowLong(hwnd, 0));
  1330. // SetFocus(hwnd);
  1331. // InvalidateRect(hwnd, NULL, FALSE);
  1332. // return 0;
  1333. //
  1334. // case WM_SETFOCUS:
  1335. // idFocus = GetWindowLong(hwnd, GWL_ID);
  1336. //
  1337. // case WM_KILLFOCUS:
  1338. // InvalidateRect(hwnd, NULL, TRUE);
  1339. // return 0;
  1340. //
  1341. // case WM_PAINT:
  1342. // hdc = BeginPaint(hwnd, &ps);
  1343. // GetClientRect(hwnd, &rect);
  1344. // Rectangle(hdc, 0, 0, rect.right, rect.bottom);
  1345. //
  1346. // if (GetWindowLong(hwnd, 0))
  1347. // {
  1348. // MoveToEx(hdc, 0, 0, NULL);
  1349. // LineTo(hdc, rect.right, rect.bottom);
  1350. // MoveToEx(hdc, 0, rect.bottom, NULL);
  1351. // LineTo(hdc, rect.right, 0);
  1352. // }
  1353. //
  1354. // if (hwnd = GetFocus())
  1355. // {
  1356. // rect.left += rect.right / 10;
  1357. // rect.right -= rect.left;
  1358. // rect.top += rect.bottom / 10;
  1359. // rect.bottom -= rect.top;
  1360. //
  1361. // SelectObject(hdc, GetStockObject(NULL_BRUSH));
  1362. // SelectObject(hdc, CreatePen(PS_DASH, 0, 0));
  1363. // Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
  1364. // DeleteObject(SelectObject(hdc, GetStockObject(BLACK_PEN)));
  1365. // }
  1366. //
  1367. // EndPaint(hwnd, &ps);
  1368. // return 0;
  1369. // }
  1370. //
  1371. // return DefWindowProc(hwnd, message, wParam, lParam);
  1372. //}
  1373.  
  1374.  
  1375. //CHECKER3
  1376.  
  1377. //#include<Windows.h>
  1378. //#define DIVISIONS 5
  1379. //
  1380. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  1381. //LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
  1382. //
  1383. //TCHAR szChildClass[] = TEXT("Checker3_Child");
  1384. //
  1385. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  1386. //{
  1387. // static TCHAR szAppName[] = TEXT("Checker3");
  1388. // HWND hwnd;
  1389. // MSG msg;
  1390. // WNDCLASS wndclass;
  1391. //
  1392. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  1393. // wndclass.lpfnWndProc = WndProc;
  1394. // wndclass.cbClsExtra = 0;
  1395. // wndclass.cbWndExtra = 0;
  1396. // wndclass.hInstance = hInstance;
  1397. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  1398. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  1399. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  1400. // wndclass.lpszMenuName = NULL;
  1401. // wndclass.lpszClassName = szAppName;
  1402. //
  1403. // if (!RegisterClass(&wndclass))
  1404. // {
  1405. // MessageBox(NULL, TEXT("Program requires Windows NT!"),
  1406. // szAppName, MB_ICONERROR);
  1407. // return 0;
  1408. // }
  1409. // wndclass.lpfnWndProc = ChildWndProc;
  1410. // wndclass.cbWndExtra = sizeof(long);
  1411. // wndclass.hIcon = NULL;
  1412. // wndclass.lpszClassName = szChildClass;
  1413. //
  1414. // hwnd = CreateWindow(szAppName, TEXT("Checker3 Mouse Hit−Test Demo"),
  1415. // WS_OVERLAPPEDWINDOW,
  1416. // CW_USEDEFAULT, CW_USEDEFAULT,
  1417. // CW_USEDEFAULT, CW_USEDEFAULT,
  1418. // NULL, NULL, hInstance, NULL);
  1419. // ShowWindow(hwnd, iCmdShow);
  1420. // UpdateWindow(hwnd);
  1421. //
  1422. // while (GetMessage(&msg, NULL, 0, 0))
  1423. // {
  1424. // TranslateMessage(&msg);
  1425. // DispatchMessage(&msg);
  1426. // }
  1427. // return msg.wParam;
  1428. //}
  1429. //
  1430. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1431. //{
  1432. // static HWND hwndChild[DIVISIONS][DIVISIONS];
  1433. // int cxBlock, cyBlock, x, y;
  1434. // switch (message)
  1435. // {
  1436. // case WM_CREATE:
  1437. // for (x = 0; x < DIVISIONS; x++)
  1438. // {
  1439. // for (y = 0; y < DIVISIONS; y++)
  1440. // {
  1441. // hwndChild[x][y] = CreateWindow(szChildClass, NULL, WS_CHILDWINDOW | WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)(y << 8 | x), (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
  1442. // return 0;
  1443. // }
  1444. // }
  1445. //
  1446. // case WM_SIZE:
  1447. // cxBlock = LOWORD(lParam) / DIVISIONS;
  1448. // cyBlock = HIWORD(lParam) / DIVISIONS;
  1449. // for (x = 0; x < DIVISIONS; x++)
  1450. // {
  1451. // for (y = 0; y < DIVISIONS; y++)
  1452. // {
  1453. // MoveWindow(hwndChild[x][y], x*cxBlock, y*cyBlock, cxBlock, cyBlock, TRUE);
  1454. // }
  1455. // }
  1456. // return 0;
  1457. //
  1458. // case WM_LBUTTONDOWN:
  1459. // MessageBeep(0);
  1460. // return 0;
  1461. //
  1462. // case WM_DESTROY:
  1463. // PostQuitMessage(0);
  1464. // return 0;
  1465. // }
  1466. // return DefWindowProc(hwnd, message, wParam, lParam);
  1467. //
  1468. //}
  1469. //
  1470. //LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1471. //{
  1472. // HDC hdc;
  1473. // PAINTSTRUCT ps;
  1474. // RECT rect;
  1475. //
  1476. // switch (message)
  1477. // {
  1478. // case WM_CREATE:
  1479. // SetWindowLong(hwnd, 0, 0);
  1480. // return 0;
  1481. //
  1482. // case WM_LBUTTONDOWN:
  1483. // SetWindowLong(hwnd, 0, 1 ^ GetWindowLong(hwnd, 0));
  1484. // InvalidateRect(hwnd, NULL, FALSE);
  1485. // return 0;
  1486. //
  1487. // case WM_PAINT:
  1488. // hdc = BeginPaint(hwnd, &ps);
  1489. // GetClientRect(hwnd, &rect);
  1490. //
  1491. // Rectangle(hdc, 0, 0, rect.right, rect.bottom);
  1492. //
  1493. // if (GetWindowLong(hwnd, 0))
  1494. // {
  1495. // MoveToEx(hdc, 0, 0, NULL);
  1496. // LineTo(hdc, rect.right, rect.bottom);
  1497. // MoveToEx(hdc, 0, rect.bottom, NULL);
  1498. // LineTo(hdc, rect.right, 0);
  1499. // }
  1500. //
  1501. // EndPaint(hwnd, &ps);
  1502. // return 0;
  1503. // }
  1504. // return DefWindowProc(hwnd, message, wParam, lParam);
  1505. //}
  1506.  
  1507.  
  1508. //CHECKER2
  1509.  
  1510. //#include<windows.h>
  1511. //#define DIVISIONS 5
  1512. //
  1513. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  1514. //
  1515. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  1516. //{
  1517. // static TCHAR szAppName[] = TEXT("Checker2");
  1518. // HWND hwnd;
  1519. // MSG msg;
  1520. // WNDCLASS wndclass;
  1521. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  1522. // wndclass.lpfnWndProc = WndProc;
  1523. // wndclass.cbClsExtra = 0;
  1524. // wndclass.cbWndExtra = 0;
  1525. // wndclass.hInstance = hInstance;
  1526. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  1527. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  1528. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  1529. // wndclass.lpszMenuName = NULL;
  1530. // wndclass.lpszClassName = szAppName;
  1531. //
  1532. // if (!RegisterClass(&wndclass))
  1533. // {
  1534. // MessageBox(NULL, TEXT("Program requires Windows NT!"),
  1535. // szAppName, MB_ICONERROR);
  1536. // return 0;
  1537. // }
  1538. // hwnd = CreateWindow(szAppName, TEXT("Checker2 Mouse Hit−Test Demo"),
  1539. // WS_OVERLAPPEDWINDOW,
  1540. // CW_USEDEFAULT, CW_USEDEFAULT,
  1541. // CW_USEDEFAULT, CW_USEDEFAULT,
  1542. // NULL, NULL, hInstance, NULL);
  1543. // ShowWindow(hwnd, iCmdShow);
  1544. // UpdateWindow(hwnd);
  1545. // while (GetMessage(&msg, NULL, 0, 0))
  1546. // {
  1547. // TranslateMessage(&msg);
  1548. // DispatchMessage(&msg);
  1549. // }
  1550. // return msg.wParam;
  1551. //}
  1552. //
  1553. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1554. //{
  1555. // static BOOL fState[DIVISIONS][DIVISIONS];
  1556. // static int cxBlock, cyBlock;
  1557. // HDC hdc;
  1558. // int x, y;
  1559. // PAINTSTRUCT ps;
  1560. // POINT point;
  1561. // RECT rect;
  1562. //
  1563. // switch (message)
  1564. // {
  1565. // case WM_SIZE:
  1566. // cxBlock = LOWORD(lParam) / DIVISIONS;
  1567. // cyBlock = HIWORD(lParam) / DIVISIONS;
  1568. // return 0;
  1569. //
  1570. // case WM_SETFOCUS:
  1571. // ShowCursor(TRUE);
  1572. // return 0;
  1573. //
  1574. // case WM_KILLFOCUS:
  1575. // ShowCursor(FALSE);
  1576. // return 0;
  1577. //
  1578. // case WM_KEYDOWN:
  1579. // GetCursorPos(&point);
  1580. // ScreenToClient(hwnd, &point);
  1581. // x = max(0, min(DIVISIONS - 1, point.x / cxBlock));
  1582. // y = max(0, min(DIVISIONS - 1, point.y / cyBlock));
  1583. //
  1584. // switch (wParam)
  1585. // {
  1586. // case VK_UP:
  1587. // y--;
  1588. // break;
  1589. //
  1590. // case VK_DOWN:
  1591. // y++;
  1592. // break;
  1593. //
  1594. // case VK_LEFT:
  1595. // x--;
  1596. // break;
  1597. //
  1598. // case VK_RIGHT:
  1599. // x++;
  1600. // break;
  1601. //
  1602. // case VK_HOME:
  1603. // x = y = 0;
  1604. // break;
  1605. //
  1606. // case VK_END:
  1607. // x = y = DIVISIONS - 1;
  1608. // break;
  1609. //
  1610. // case VK_RETURN:
  1611. // case VK_SPACE:
  1612. // SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(x*cxBlock, y*cyBlock));
  1613. // break;
  1614. //
  1615. // }
  1616. //
  1617. // x = (x + DIVISIONS) % DIVISIONS;
  1618. // y = (y + DIVISIONS) % DIVISIONS;
  1619. //
  1620. // point.x = x*cxBlock + cxBlock / 2;
  1621. // point.y = y*cyBlock + cyBlock / 2;
  1622. //
  1623. // ClientToScreen(hwnd, &point);
  1624. // SetCursorPos(point.x, point.y);
  1625. // return 0;
  1626. //
  1627. // case WM_LBUTTONDOWN:
  1628. // x = LOWORD(lParam) / cxBlock;
  1629. // y = HIWORD(lParam) / cyBlock;
  1630. //
  1631. // if (x < DIVISIONS && y < DIVISIONS)
  1632. // {
  1633. // fState[x][y] ^= 1;
  1634. // rect.left = x*cxBlock;
  1635. // rect.top = y*cyBlock;
  1636. // rect.right = (x + 1) *cxBlock;
  1637. // rect.bottom = (y + 1) * cyBlock;
  1638. //
  1639. // InvalidateRect(hwnd, &rect, FALSE);
  1640. //
  1641. // }
  1642. // else MessageBeep(0);
  1643. // return 0;
  1644. //
  1645. // case WM_PAINT:
  1646. // hdc = BeginPaint(hwnd, &ps);
  1647. // for (x = 0; x < DIVISIONS; x++)
  1648. // for (y = 0; y < DIVISIONS; y++)
  1649. // {
  1650. // Rectangle(hdc, x*cxBlock, y*cyBlock, (x + 1)*cxBlock, (y + 1)*cyBlock);
  1651. // if (fState[x][y])
  1652. // {
  1653. // MoveToEx(hdc, x*cxBlock, y*cyBlock, NULL);
  1654. // LineTo(hdc, (x + 1)*cxBlock, (y + 1)*cyBlock);
  1655. // MoveToEx(hdc, x*cxBlock, (y + 1)*cyBlock, NULL);
  1656. // LineTo(hdc, (x + 1)*cxBlock, y*cyBlock);
  1657. // }
  1658. // }
  1659. // EndPaint(hwnd, &ps);
  1660. // return 0;
  1661. //
  1662. // case WM_DESTROY:
  1663. // PostQuitMessage(0);
  1664. // return 0;
  1665. // }
  1666. //
  1667. // return DefWindowProc(hwnd, message, wParam, lParam);
  1668. //}
  1669.  
  1670.  
  1671. //CHECKER1
  1672.  
  1673. //#include<Windows.h>
  1674. //#define DIVISIONS 5
  1675. //
  1676. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  1677. //
  1678. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  1679. //{
  1680. // static TCHAR szAppName[] = TEXT("Checker1");
  1681. // HWND hwnd;
  1682. // MSG msg;
  1683. // WNDCLASS wndclass;
  1684. // wndclass.style = CS_HREDRAW || CS_VREDRAW;
  1685. // wndclass.lpfnWndProc = WndProc;
  1686. // wndclass.cbClsExtra = 0;
  1687. // wndclass.cbWndExtra = 0;
  1688. // wndclass.hInstance = hInstance;
  1689. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  1690. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  1691. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  1692. // wndclass.lpszMenuName = NULL;
  1693. // wndclass.lpszClassName = szAppName;
  1694. //
  1695. // if (!RegisterClass(&wndclass))
  1696. // {
  1697. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  1698. // return 0;
  1699. // }
  1700. //
  1701. // hwnd = CreateWindow(szAppName, TEXT("Checker1 Mouse Hit-Test Demo"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  1702. // ShowWindow(hwnd, iCmdShow);
  1703. // UpdateWindow(hwnd);
  1704. //
  1705. // while (GetMessage(&msg, NULL, 0, 0))
  1706. // {
  1707. // TranslateMessage(&msg);
  1708. // DispatchMessage(&msg);
  1709. // }
  1710. // return msg.wParam;
  1711. //
  1712. //}
  1713. //
  1714. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1715. //{
  1716. // static BOOL fState[DIVISIONS][DIVISIONS];
  1717. // static int cxBlock, cyBlock;
  1718. // HDC hdc;
  1719. // int x, y;
  1720. // PAINTSTRUCT ps;
  1721. // RECT rect;
  1722. //
  1723. // switch (message)
  1724. // {
  1725. // case WM_SIZE:
  1726. // cxBlock = LOWORD(lParam) / DIVISIONS;
  1727. // cyBlock = HIWORD(lParam) / DIVISIONS;
  1728. // return 0;
  1729. //
  1730. // case WM_LBUTTONDOWN:
  1731. // x = LOWORD(lParam) / cxBlock;
  1732. // y = HIWORD(lParam) / cyBlock;
  1733. //
  1734. // if (x < DIVISIONS && y < DIVISIONS)
  1735. // {
  1736. // fState[x][y] ^= 1;
  1737. // rect.left = x* cxBlock;
  1738. // rect.top = y*cyBlock;
  1739. // rect.right = (x + 1)*cxBlock;
  1740. // rect.bottom = (y + 1)*cyBlock;
  1741. //
  1742. // InvalidateRect(hwnd, &rect, FALSE);
  1743. // }
  1744. // else
  1745. // {
  1746. // MessageBeep(0);
  1747. // }
  1748. // return 0;
  1749. //
  1750. // case WM_PAINT:
  1751. // hdc = BeginPaint(hwnd, &ps);
  1752. // for (x = 0; x < DIVISIONS; x++)
  1753. // for (y = 0; y < DIVISIONS; y++)
  1754. // {
  1755. // Rectangle(hdc, x*cxBlock, y*cyBlock, (x + 1)*cxBlock, (y + 1)*cyBlock);
  1756. // if (fState[x][y])
  1757. // {
  1758. // MoveToEx(hdc, x * cxBlock, y * cyBlock, NULL);
  1759. // LineTo(hdc, (x + 1) * cxBlock, (y + 1) * cyBlock);
  1760. // MoveToEx(hdc, x * cxBlock, (y + 1) * cyBlock, NULL);
  1761. // LineTo(hdc, (x + 1) * cxBlock, y * cyBlock);
  1762. // }
  1763. // }
  1764. // EndPaint(hwnd, &ps);
  1765. // return 0;
  1766. //
  1767. // case WM_DESTROY:
  1768. // PostQuitMessage(0);
  1769. // return 0;
  1770. // }
  1771. // return DefWindowProc(hwnd, message, wParam, lParam);
  1772. //
  1773. //}
  1774.  
  1775.  
  1776. //CONNECT
  1777.  
  1778. //#include<Windows.h>
  1779. //#define MAXPOINTS 1000
  1780. //
  1781. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  1782. //
  1783. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  1784. //{
  1785. // static TCHAR szAppName[] = TEXT("Connect");
  1786. // HWND hwnd;
  1787. // MSG msg;
  1788. // WNDCLASS wndclass;
  1789. //
  1790. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  1791. // wndclass.lpfnWndProc = WndProc;
  1792. // wndclass.cbClsExtra = 0;
  1793. // wndclass.cbWndExtra = 0;
  1794. // wndclass.hInstance = hInstance;
  1795. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  1796. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  1797. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  1798. // wndclass.lpszMenuName = NULL;
  1799. // wndclass.lpszClassName = szAppName;
  1800. //
  1801. // if (!RegisterClass(&wndclass))
  1802. // {
  1803. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  1804. // return 0;
  1805. // }
  1806. //
  1807. // hwnd = CreateWindow(szAppName, TEXT("Connect-the-Points Mouse Demo"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  1808. // ShowWindow(hwnd, iCmdShow);
  1809. // UpdateWindow(hwnd);
  1810. //
  1811. // while (GetMessage(&msg, NULL, 0, 0))
  1812. // {
  1813. // TranslateMessage(&msg);
  1814. // DispatchMessage(&msg);
  1815. // }
  1816. // return msg.wParam;
  1817. //
  1818. //}
  1819. //
  1820. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1821. //{
  1822. // static POINT pt[MAXPOINTS];
  1823. // static int iCount;
  1824. // HDC hdc;
  1825. // int i, j;
  1826. // PAINTSTRUCT ps;
  1827. //
  1828. // switch (message)
  1829. // {
  1830. // case WM_LBUTTONDOWN:
  1831. // iCount = 0;
  1832. // InvalidateRect(hwnd, NULL, TRUE);
  1833. // return 0;
  1834. //
  1835. // case WM_MOUSEMOVE:
  1836. // if (wParam & MK_LBUTTON && iCount < 1000)
  1837. // {
  1838. // pt[iCount].x = LOWORD(lParam);
  1839. // pt[iCount++].y = HIWORD(lParam);
  1840. //
  1841. // hdc = GetDC(hwnd);
  1842. // SetPixel(hdc, LOWORD(lParam), HIWORD(lParam), 0);
  1843. // ReleaseDC(hwnd, hdc);
  1844. // }
  1845. // return 0;
  1846. //
  1847. // case WM_LBUTTONUP:
  1848. // InvalidateRect(hwnd, NULL, FALSE);
  1849. // return 0;
  1850. //
  1851. // case WM_PAINT:
  1852. // hdc = BeginPaint(hwnd, &ps);
  1853. // SetCursor(LoadCursor(NULL, IDC_WAIT));
  1854. // ShowCursor(TRUE);
  1855. // for (i = 0; i < iCount - 1; i++)
  1856. // {
  1857. // for (j = i + 1; j < iCount; j++)
  1858. // {
  1859. // MoveToEx(hdc, pt[i].x, pt[i].y, NULL);
  1860. // LineTo(hdc, pt[j].x, pt[j].y);
  1861. // }
  1862. // }
  1863. //
  1864. // ShowCursor(FALSE);
  1865. // SetCursor(LoadCursor(NULL,IDC_ARROW));
  1866. // EndPaint(hwnd, &ps);
  1867. // return 0;
  1868. //
  1869. // case WM_DESTROY:
  1870. // PostQuitMessage(0);
  1871. // return 0;
  1872. // }
  1873. // return DefWindowProc(hwnd, message, wParam, lParam);
  1874. //}
  1875.  
  1876.  
  1877. //TYPER
  1878.  
  1879. //#include<windows.h>
  1880. //#define BUFFER(x,y) * (pBuffer+y * cxBuffer +x)
  1881. //
  1882. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  1883. //
  1884. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  1885. //{
  1886. // static TCHAR szAppName[] = TEXT("Typer");
  1887. // HWND hwnd;
  1888. // MSG msg;
  1889. // WNDCLASS wndclass;
  1890. //
  1891. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  1892. // wndclass.lpfnWndProc = WndProc;
  1893. // wndclass.cbClsExtra = 0;
  1894. // wndclass.cbWndExtra = 0;
  1895. // wndclass.hInstance = hInstance;
  1896. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  1897. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  1898. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  1899. // wndclass.lpszMenuName = NULL;
  1900. // wndclass.lpszClassName = szAppName;
  1901. //
  1902. // if (!RegisterClass(&wndclass))
  1903. // {
  1904. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  1905. // return 0;
  1906. // }
  1907. //
  1908. // hwnd = CreateWindow(szAppName, TEXT("Typing Program"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  1909. // ShowWindow(hwnd, iCmdShow);
  1910. // UpdateWindow(hwnd);
  1911. //
  1912. // while (GetMessage(&msg, NULL, 0, 0))
  1913. // {
  1914. // TranslateMessage(&msg);
  1915. // DispatchMessage(&msg);
  1916. // }
  1917. // return msg.wParam;
  1918. //
  1919. //}
  1920. //
  1921. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  1922. //{
  1923. // static DWORD dwCharSet = DEFAULT_CHARSET;
  1924. // static int cxChar, cyChar, cxClient, cyClient, cxBuffer, cyBuffer, xCaret, yCaret;
  1925. // static TCHAR * pBuffer = NULL;
  1926. // HDC hdc;
  1927. // int x, y, i;
  1928. // PAINTSTRUCT ps;
  1929. // TEXTMETRIC tm;
  1930. //
  1931. // switch (message)
  1932. // {
  1933. // case WM_INPUTLANGCHANGE:
  1934. // dwCharSet = wParam;
  1935. //
  1936. // case WM_CREATE:
  1937. // hdc = GetDC(hwnd);
  1938. // SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
  1939. // dwCharSet, 0, 0, 0, FIXED_PITCH, NULL));
  1940. // GetTextMetrics(hdc, &tm);
  1941. // cxChar = tm.tmAveCharWidth;
  1942. // cyChar = tm.tmHeight;
  1943. // DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
  1944. // ReleaseDC(hwnd, hdc);
  1945. //
  1946. // case WM_SIZE:
  1947. // cxClient = LOWORD(lParam);
  1948. // cyClient = HIWORD(lParam);
  1949. //
  1950. // cxBuffer = max(1, cxClient / cxChar);
  1951. // cyBuffer = max(1, cyClient / cyChar);
  1952. //
  1953. // if (pBuffer != NULL) free(pBuffer);
  1954. // pBuffer = (TCHAR *)malloc(cxBuffer * cyBuffer * sizeof(TCHAR));
  1955. // for (y = 0; y < cyBuffer; y++)
  1956. // for (x = 0; x < cxBuffer; x++)
  1957. // {
  1958. // BUFFER(x, y) = ' ';
  1959. // }
  1960. // xCaret = 0;
  1961. // yCaret = 0;
  1962. //
  1963. // if (hwnd = GetFocus()) SetCaretPos(xCaret * cxChar, yCaret * cyChar);
  1964. // InvalidateRect(hwnd, NULL, TRUE);
  1965. // return 0;
  1966. //
  1967. // case WM_SETFOCUS:
  1968. // CreateCaret(hwnd, NULL, cxChar, cyChar);
  1969. // SetCaretPos(xCaret * cxChar, yCaret * cyChar);
  1970. // ShowCaret(hwnd);
  1971. // return 0;
  1972. //
  1973. // case WM_KILLFOCUS:
  1974. // HideCaret(hwnd);
  1975. // DestroyCaret();
  1976. // return 0;
  1977. //
  1978. // case WM_KEYDOWN:
  1979. // switch (wParam)
  1980. // {
  1981. // case VK_HOME:
  1982. // xCaret = 0;
  1983. // break;
  1984. //
  1985. // case VK_END:
  1986. // xCaret = cxBuffer - 1;
  1987. // break;
  1988. //
  1989. // case VK_PRIOR:
  1990. // yCaret = 0;
  1991. // break;
  1992. //
  1993. // case VK_NEXT:
  1994. // yCaret = cyBuffer - 1;
  1995. // break;
  1996. //
  1997. // case VK_LEFT:
  1998. // xCaret = max(xCaret - 1, 0);
  1999. // break;
  2000. //
  2001. // case VK_RIGHT:
  2002. // xCaret = min(xCaret + 1, cxBuffer - 1);
  2003. // break;
  2004. //
  2005. // case VK_UP:
  2006. // yCaret = max(yCaret - 1, 0);
  2007. // break;
  2008. //
  2009. // case VK_DOWN:
  2010. // yCaret = min(yCaret + 1, cyBuffer - 1);
  2011. // break;
  2012. //
  2013. // case VK_DELETE:
  2014. // for (x = xCaret; x < cxBuffer - 1; x++)
  2015. // {
  2016. // BUFFER(x, yCaret) = BUFFER(x + 1, yCaret);
  2017. // }
  2018. // BUFFER(cxBuffer - 1, yCaret) = ' ';
  2019. // HideCaret(hwnd);
  2020. // hdc = GetDC(hwnd);
  2021. // SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
  2022. // dwCharSet, 0, 0, 0, FIXED_PITCH, NULL));
  2023. // TextOut(hdc, xCaret * cxChar, yCaret * cyChar, &BUFFER(xCaret, yCaret), cxBuffer - xCaret);
  2024. // DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
  2025. // ReleaseDC(hwnd, hdc);
  2026. // ShowCaret(hwnd);
  2027. // break;
  2028. //
  2029. // }
  2030. // SetCaretPos(xCaret*cxChar, yCaret*cyChar);
  2031. // return 0;
  2032. //
  2033. // case WM_CHAR:
  2034. // for (i = 0; i < (int)LOWORD(lParam); i++)
  2035. // {
  2036. // switch (wParam)
  2037. // {
  2038. // case '\b':
  2039. // if (xCaret > 0)
  2040. // {
  2041. // xCaret--;
  2042. // SendMessage(hwnd, WM_KEYDOWN, VK_DELETE, 1);
  2043. // }
  2044. // break;
  2045. //
  2046. // case '\t':
  2047. // do
  2048. // {
  2049. // SendMessage(hwnd, WM_CHAR, ' ', 1);
  2050. // } while (xCaret % 8 != 0);
  2051. // break;
  2052. //
  2053. // case '\n':
  2054. // if (++yCaret == cyBuffer) yCaret = 0;
  2055. // break;
  2056. //
  2057. // case '\r':
  2058. // xCaret = 0;
  2059. // if (++yCaret == cyBuffer) yCaret = 0;
  2060. // break;
  2061. //
  2062. // case '\x1B':
  2063. // for (y = 0; y < cyBuffer; y++)
  2064. // {
  2065. // for (x = 0; x < cxBuffer; x++)
  2066. // {
  2067. // BUFFER(x,y) = ' ';
  2068. // }
  2069. // }
  2070. // xCaret = 0;
  2071. // yCaret = 0;
  2072. //
  2073. // InvalidateRect(hwnd, NULL, FALSE);
  2074. // break;
  2075. //
  2076. // default:
  2077. // BUFFER(xCaret, yCaret) = (TCHAR)wParam;
  2078. // HideCaret(hwnd);
  2079. // hdc = GetDC(hwnd);
  2080. // SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
  2081. // dwCharSet, 0, 0, 0, FIXED_PITCH, NULL));
  2082. // TextOut(hdc, xCaret * cxChar, yCaret * cyChar, &BUFFER(xCaret, yCaret), 1);
  2083. // DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
  2084. // ReleaseDC(hwnd, hdc);
  2085. // ShowCaret(hwnd);
  2086. //
  2087. // if (++xCaret = cxBuffer)
  2088. // {
  2089. // xCaret = 0;
  2090. // if (++yCaret == cyBuffer) yCaret = 0;
  2091. // }
  2092. // break;
  2093. //
  2094. // }
  2095. // }
  2096. //
  2097. // SetCaretPos(xCaret*cxChar, yCaret * cyChar);
  2098. // return 0;
  2099. //
  2100. // case WM_PAINT:
  2101. // hdc = BeginPaint(hwnd, &ps);
  2102. // SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
  2103. // dwCharSet, 0, 0, 0, FIXED_PITCH, NULL));
  2104. // for (y = 0; y < cyBuffer; y++)
  2105. // {
  2106. // TextOut(hdc, 0, y*cyChar, &BUFFER(0, y), cxBuffer);
  2107. // }
  2108. // DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
  2109. // EndPaint(hwnd, &ps);
  2110. // return 0;
  2111. //
  2112. // case WM_DESTROY:
  2113. // PostQuitMessage(0);
  2114. // return 0;
  2115. // }
  2116. // return DefWindowProc(hwnd, message, wParam, lParam);
  2117. //
  2118. //}
  2119.  
  2120.  
  2121. //KEYVIEW2
  2122.  
  2123. //#include<windows.h>
  2124. //
  2125. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  2126. //
  2127. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  2128. //{
  2129. // static TCHAR szAppName[] = TEXT("KeyView2");
  2130. // HWND hwnd;
  2131. // MSG msg;
  2132. // WNDCLASS wndclass;
  2133. //
  2134. // wndclass.style = CS_HREDRAW || CS_VREDRAW;
  2135. // wndclass.lpfnWndProc = WndProc;
  2136. // wndclass.cbClsExtra = 0;
  2137. // wndclass.cbWndExtra = 0;
  2138. // wndclass.hInstance = hInstance;
  2139. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  2140. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  2141. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  2142. // wndclass.lpszMenuName = NULL;
  2143. // wndclass.lpszClassName = szAppName;
  2144. //
  2145. // if (!RegisterClass(&wndclass))
  2146. // {
  2147. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  2148. // return 0;
  2149. // }
  2150. //
  2151. // hwnd = CreateWindow(szAppName, TEXT("Keyboard Message Viewer #2"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  2152. // ShowWindow(hwnd, iCmdShow);
  2153. // UpdateWindow(hwnd);
  2154. //
  2155. // while (GetMessage(&msg, NULL, 0, 0))
  2156. // {
  2157. // TranslateMessage(&msg);
  2158. // DispatchMessage(&msg);
  2159. // }
  2160. // return msg.wParam;
  2161. //
  2162. //}
  2163. //
  2164. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  2165. //{
  2166. // static DWORD dwCharSet = DEFAULT_CHARSET;
  2167. // static int cxClientMax, cyClientMax, cxClient, cyClient, cxChar, cyChar;
  2168. // static int cLinesMax, cLines;
  2169. // static PMSG pmsg;
  2170. // static RECT rectScroll;
  2171. // static TCHAR szTop[] = TEXT("Message Key Char ") TEXT("Repeat Scan Ext ALT Prev Tran");
  2172. // static TCHAR szUnd[] = TEXT("_______ ___ ____") TEXT("______ ____ ___ ___ ____ ____");
  2173. // static TCHAR * szFormat[2] = {
  2174. // TEXT("%−13s %3d %−15s%c%6u %4d %3s %3s %4s %4s"),
  2175. // TEXT("%−13s 0x%04X%1s%c %6u %4d %3s %3s %4s %4s") };
  2176. // static TCHAR * szYes = TEXT("Yes");
  2177. // static TCHAR * szNo = TEXT("No");
  2178. // static TCHAR * szDown = TEXT("Down");
  2179. // static TCHAR * szUp = TEXT("Up");
  2180. //
  2181. // static TCHAR * szMessage[] = {
  2182. // TEXT("WM_KEYDOWN"), TEXT("WM_KEYUP"),
  2183. // TEXT("WM_CHAR"), TEXT("WM_DEADCHAR"),
  2184. // TEXT("WM_SYSKEYDOWN"), TEXT("WM_SYSKEYUP"),
  2185. // TEXT("WM_SYSCHAR"), TEXT("WM_SYSDEADCHAR") };
  2186. //
  2187. // HDC hdc;
  2188. // int i, iType;
  2189. // PAINTSTRUCT ps;
  2190. // TCHAR szBuffer[128], szKeyName[32];
  2191. // TEXTMETRIC tm;
  2192. //
  2193. // switch (message)
  2194. // {
  2195. // case WM_INPUTLANGCHANGE:
  2196. // dwCharSet = wParam;
  2197. // case WM_CREATE:
  2198. // case WM_DISPLAYCHANGE:
  2199. // cxClientMax = GetSystemMetrics(SM_CXMAXIMIZED);
  2200. // cyClientMax = GetSystemMetrics(SM_CYMAXIMIZED);
  2201. //
  2202. // hdc = GetDC(hwnd);
  2203. // SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
  2204. // dwCharSet, 0, 0, 0, FIXED_PITCH, NULL));
  2205. //
  2206. // GetTextMetrics(hdc, &tm);
  2207. // cxChar = tm.tmAveCharWidth;
  2208. // cyChar = tm.tmHeight;
  2209. // DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
  2210. // ReleaseDC(hwnd, hdc);
  2211. //
  2212. // if (pmsg) free(pmsg);
  2213. // cLinesMax = cyClientMax / cyChar;
  2214. // pmsg = (PMSG)malloc(cLinesMax * sizeof(MSG));
  2215. // cLines = 0;
  2216. //
  2217. // case WM_SIZE:
  2218. // cxClient = LOWORD(lParam);
  2219. // cyClient = HIWORD(lParam);
  2220. // rectScroll.left = 0;
  2221. // rectScroll.right = cxClient;
  2222. // rectScroll.top = cyChar;
  2223. // rectScroll.bottom = cyChar * (cyClient / cyChar);
  2224. //
  2225. // InvalidateRect(hwnd, NULL, TRUE);
  2226. //
  2227. // if (message == WM_INPUTLANGCHANGE) return TRUE;
  2228. //
  2229. // return 0;
  2230. //
  2231. // case WM_KEYDOWN:
  2232. // case WM_KEYUP:
  2233. // case WM_CHAR:
  2234. // case WM_DEADCHAR:
  2235. // case WM_SYSKEYDOWN:
  2236. // case WM_SYSKEYUP:
  2237. // case WM_SYSCHAR:
  2238. // case WM_SYSDEADCHAR:
  2239. // for (i = cLinesMax - 1; i > 0; i--)
  2240. // {
  2241. // pmsg[i] = pmsg[i - 1];
  2242. // }
  2243. //
  2244. // pmsg[0].hwnd = hwnd;
  2245. // pmsg[0].message = message;
  2246. // pmsg[0].wParam = wParam;
  2247. // pmsg[0].lParam = lParam;
  2248. //
  2249. // cLines = min(cLines + 1, cLinesMax);
  2250. // ScrollWindow(hwnd, 0, -cyChar, &rectScroll, &rectScroll);
  2251. // break;
  2252. //
  2253. // case WM_PAINT:
  2254. // hdc = BeginPaint(hwnd, &ps);
  2255. // SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
  2256. // dwCharSet, 0, 0, 0, FIXED_PITCH, NULL));
  2257. //
  2258. // SetBkMode(hdc, TRANSPARENT);
  2259. // TextOut(hdc, 0, 0, szTop, lstrlen(szTop));
  2260. // TextOut(hdc, 0, 0, szUnd, lstrlen(szUnd));
  2261. // for (i = 0; i < min(cLines, cyClient / cyChar - 1); i++)
  2262. // {
  2263. // iType = pmsg[i].message == WM_CHAR || pmsg[i].message == WM_SYSCHAR ||
  2264. // pmsg[i].message == WM_DEADCHAR ||
  2265. // pmsg[i].message == WM_SYSDEADCHAR;
  2266. // }
  2267. //
  2268. // GetKeyNameText(pmsg[i].lParam, szKeyName, sizeof(szKeyName) / sizeof(TCHAR));
  2269. // TextOut(hdc, 0, (cyClient / cyChar - 1 - i)*cyChar, szBuffer, wsprintf(szBuffer, szFormat[iType], szMessage[pmsg[i].message - WM_KEYFIRST],
  2270. // pmsg[i].wParam,
  2271. // (iType ? TEXT(" ") : szKeyName),
  2272. // (iType ? pmsg[i].wParam : ' '),
  2273. // LOWORD(pmsg[i].lParam),
  2274. // HIWORD(pmsg[i].lParam) & 0xFF,
  2275. // 0x01000000 & pmsg[i].lParam ? szYes : szNo,
  2276. // 0x20000000 & pmsg[i].lParam ? szYes : szNo,
  2277. // 0x40000000 & pmsg[i].lParam ? szDown : szUp,
  2278. // 0x80000000 & pmsg[i].lParam ? szUp : szDown));
  2279. //
  2280. // DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
  2281. // EndPaint(hwnd, &ps);
  2282. // return 0;
  2283. //
  2284. // case WM_DESTROY:
  2285. // PostQuitMessage(0);
  2286. // return 0;
  2287. // }
  2288. // return DefWindowProc(hwnd, message, wParam, lParam);
  2289. //
  2290. //}
  2291.  
  2292.  
  2293. //STOKFONT
  2294.  
  2295. //#include<Windows.h>
  2296. //
  2297. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  2298. //
  2299. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  2300. //{
  2301. // static TCHAR szAppName[] = TEXT("StokFont");
  2302. // HWND hwnd;
  2303. // MSG msg;
  2304. // WNDCLASS wndclass;
  2305. //
  2306. // wndclass.style = CS_HREDRAW || CS_VREDRAW;
  2307. // wndclass.lpfnWndProc = WndProc;
  2308. // wndclass.cbClsExtra = 0;
  2309. // wndclass.cbWndExtra = 0;
  2310. // wndclass.hInstance = hInstance;
  2311. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  2312. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  2313. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  2314. // wndclass.lpszMenuName = NULL;
  2315. // wndclass.lpszClassName = szAppName;
  2316. //
  2317. // if (!RegisterClass(&wndclass))
  2318. // {
  2319. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  2320. // return 0;
  2321. // }
  2322. //
  2323. // hwnd = CreateWindow(szAppName, TEXT("Stock Fonts"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  2324. // ShowWindow(hwnd, iCmdShow);
  2325. // UpdateWindow(hwnd);
  2326. //
  2327. // while (GetMessage(&msg, NULL, 0, 0))
  2328. // {
  2329. // TranslateMessage(&msg);
  2330. // DispatchMessage(&msg);
  2331. // }
  2332. // return msg.wParam;
  2333. //
  2334. //}
  2335. //
  2336. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  2337. //{
  2338. // static struct
  2339. // {
  2340. // int idStockFont;
  2341. // TCHAR * szStockFont;
  2342. // }
  2343. //
  2344. // stockfont[] = { OEM_FIXED_FONT, (TCHAR*)"OEM_FIXED_FONT",
  2345. // ANSI_FIXED_FONT, (TCHAR*)"ANSI_FIXED_FONT",
  2346. // ANSI_VAR_FONT, (TCHAR*)"ANSI_VAR_FONT",
  2347. // SYSTEM_FONT, (TCHAR*)"SYSTEM_FONT",
  2348. // DEVICE_DEFAULT_FONT, (TCHAR*)"DEVICE_DEFAULT_FONT",
  2349. // SYSTEM_FIXED_FONT, (TCHAR*)"SYSTEM_FIXED_FONT",
  2350. // DEFAULT_GUI_FONT, (TCHAR*)"DEFAULT_GUI_FONT" };
  2351. //
  2352. // static int iFont, cFonts = sizeof(stockfont) / sizeof(stockfont[0]);
  2353. // HDC hdc;
  2354. // int i, x, y, cxGrid, cyGrid;
  2355. // PAINTSTRUCT ps;
  2356. // TCHAR szFaceName[LF_FACESIZE], szBuffer[LF_FACESIZE + 64];
  2357. // TEXTMETRIC tm;
  2358. //
  2359. // switch (message)
  2360. // {
  2361. // case WM_CREATE:
  2362. // SetScrollRange(hwnd, SB_VERT, 0, cFonts - 1, TRUE);
  2363. // return 0;
  2364. //
  2365. // case WM_DISPLAYCHANGE:
  2366. // InvalidateRect(hwnd, NULL, TRUE);
  2367. // return 0;
  2368. //
  2369. // case WM_VSCROLL:
  2370. // switch (LOWORD(wParam))
  2371. // {
  2372. // case SB_TOP: iFont = 0; break;
  2373. // case SB_BOTTOM: iFont = cFonts - 1; break;
  2374. // case SB_LINEUP:
  2375. // case SB_PAGEUP: iFont -= 1; break;
  2376. // case SB_LINEDOWN:
  2377. // case SB_PAGEDOWN: iFont += 1; break;
  2378. // case SB_THUMBPOSITION: iFont = HIWORD(wParam); break;
  2379. // }
  2380. // iFont = max(0, min(cFonts - 1, iFont));
  2381. // SetScrollPos(hwnd, SB_VERT, iFont, TRUE);
  2382. // InvalidateRect(hwnd, NULL, TRUE);
  2383. // return 0;
  2384. //
  2385. // case WM_KEYDOWN:
  2386. // switch (wParam)
  2387. // {
  2388. // case VK_HOME: SendMessage(hwnd, WM_VSCROLL, SB_TOP, 0); break;
  2389. // case VK_END: SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, 0); break;
  2390. // case VK_PRIOR:
  2391. // case VK_LEFT:
  2392. // case VK_UP: SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0); break;
  2393. // case VK_NEXT:
  2394. // case VK_RIGHT:
  2395. // case VK_DOWN: SendMessage(hwnd, WM_VSCROLL, SB_PAGEDOWN, 0); break;
  2396. // }
  2397. // return 0;
  2398. //
  2399. // case WM_PAINT:
  2400. // hdc = BeginPaint(hwnd, &ps);
  2401. // SelectObject(hdc, GetStockObject(stockfont[iFont].idStockFont));
  2402. // GetTextFace(hdc, LF_FACESIZE, szFaceName);
  2403. // GetTextMetrics(hdc, &tm);
  2404. // cxGrid = max(3 * tm.tmAveCharWidth, 2 * tm.tmMaxCharWidth);
  2405. // cyGrid = tm.tmHeight + 3;
  2406. //
  2407. // TextOut(hdc, 0, 0, szBuffer, wsprintf(szBuffer, TEXT("%s:Face Name = %s, CharSet = %i"), stockfont[iFont].szStockFont, szFaceName, tm.tmCharSet));
  2408. // SetTextAlign(hdc, TA_TOP | TA_CENTER);
  2409. //
  2410. // for (i = 0; i < 17; i++)
  2411. // {
  2412. // MoveToEx(hdc, (i + 2) * cxGrid, 2 * cyGrid, NULL);
  2413. // LineTo(hdc, (i + 2) * cxGrid, 19 * cyGrid);
  2414. // MoveToEx(hdc, cxGrid, (i + 3) * cyGrid, NULL);
  2415. // LineTo(hdc, 18 * cxGrid, (i + 3) * cyGrid);
  2416. // }
  2417. //
  2418. //
  2419. // for (i = 0; i < 16; i++)
  2420. // {
  2421. // TextOut(hdc, (2 * i + 5) * cxGrid / 2, 2 * cyGrid + 2, szBuffer,
  2422. // wsprintf(szBuffer, TEXT("%X−"), i));
  2423. // TextOut(hdc, 3 * cxGrid / 2, (i + 3) * cyGrid + 2, szBuffer,
  2424. // wsprintf(szBuffer, TEXT("−%X"), i));
  2425. // }
  2426. //
  2427. //
  2428. // for (y = 0; y < 16; y++)
  2429. // for (x = 0; x < 16; x++)
  2430. // {
  2431. // TextOut(hdc, (2 * x + 5) * cxGrid / 2,
  2432. // (y + 3) * cyGrid + 2, szBuffer,
  2433. // wsprintf(szBuffer, TEXT("%c"), 16 * x + y));
  2434. // }
  2435. //
  2436. // EndPaint(hwnd, &ps);
  2437. // return 0;
  2438. //
  2439. // case WM_DESTROY:
  2440. // PostQuitMessage(0);
  2441. // return 0;
  2442. // }
  2443. // return DefWindowProc(hwnd, message, wParam, lParam);
  2444. //
  2445. //}
  2446.  
  2447.  
  2448. //KEWVIEW1
  2449.  
  2450. //#include<Windows.h>
  2451. //
  2452. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  2453. //
  2454. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  2455. //{
  2456. // static TCHAR szAppName[] = TEXT("KeyView1");
  2457. // HWND hwnd;
  2458. // MSG msg;
  2459. // WNDCLASS wndclass;
  2460. //
  2461. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  2462. // wndclass.lpfnWndProc = WndProc;
  2463. // wndclass.cbClsExtra = 0;
  2464. // wndclass.cbWndExtra = 0;
  2465. // wndclass.hInstance = hInstance;
  2466. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  2467. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  2468. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  2469. // wndclass.lpszMenuName = NULL;
  2470. // wndclass.lpszClassName = szAppName;
  2471. //
  2472. // if (!RegisterClass(&wndclass))
  2473. // {
  2474. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  2475. // return 0;
  2476. // }
  2477. // hwnd = CreateWindow(szAppName, TEXT("Keyboard Message Viewer #1"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  2478. // ShowWindow(hwnd, iCmdShow);
  2479. // UpdateWindow(hwnd);
  2480. //
  2481. // while (GetMessage(&msg, NULL, 0, 0))
  2482. // {
  2483. // TranslateMessage(&msg);
  2484. // DispatchMessage(&msg);
  2485. // }
  2486. // return msg.wParam;
  2487. //
  2488. //}
  2489. //
  2490. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  2491. //{
  2492. // static int cxClientMax, cyClientMax, cxClient, cyClient, cxChar, cyChar;
  2493. // static int cLinesMax, cLines;
  2494. // static PMSG pmsg;
  2495. // static RECT rectScroll;
  2496. // static TCHAR szTop[] = TEXT("Message Key Char") TEXT("Repeat Scan Ext ALT Prev Tran");
  2497. // static TCHAR szUnd[] = TEXT("_______ ___ ____") TEXT("______ ____ ___ ___ ____ ____");
  2498. //
  2499. // static TCHAR * szFormat[2] = {
  2500. // TEXT("%−13s %3d %−15s%c%6u %4d %3s %3s %4s %4s"),
  2501. // TEXT("%−13s 0x%04X%1s%c %6u %4d %3s %3s %4s %4s") };
  2502. // static TCHAR * szYes = TEXT("Yes");
  2503. // static TCHAR * szNo = TEXT("No");
  2504. // static TCHAR * szDown = TEXT("Down");
  2505. // static TCHAR * szUp = TEXT("Up");
  2506. //
  2507. // static TCHAR * szMessage[] = {
  2508. // TEXT("WM_KEYDOWN"), TEXT("WM_KEYUP"),
  2509. // TEXT("WM_CHAR"), TEXT("WM_DEADCHAR"),
  2510. // TEXT("WM_SYSKEYDOWN"), TEXT("WM_SYSKEYUP"),
  2511. // TEXT("WM_SYSCHAR"), TEXT("WM_SYSDEADCHAR") };
  2512. //
  2513. // HDC hdc;
  2514. // int i, iType;
  2515. // PAINTSTRUCT ps;
  2516. // TCHAR szBuffer[128], szKeyName[32];
  2517. // TEXTMETRIC tm;
  2518. //
  2519. // switch (message)
  2520. // {
  2521. // case WM_CREATE:
  2522. // case WM_DISPLAYCHANGE:
  2523. // cxClientMax = GetSystemMetrics(SM_CXMAXIMIZED);
  2524. // cyClientMax = GetSystemMetrics(SM_CYMAXIMIZED);
  2525. //
  2526. // hdc = GetDC(hwnd);
  2527. // SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
  2528. // GetTextMetrics(hdc, &tm);
  2529. // cxChar = tm.tmAveCharWidth;
  2530. // cyChar = tm.tmHeight;
  2531. // ReleaseDC(hwnd, hdc);
  2532. //
  2533. // if (pmsg) free(pmsg);
  2534. // cLinesMax = cyClientMax / cyChar;
  2535. // pmsg = (PMSG)malloc(cLinesMax * sizeof(MSG));
  2536. // cLines = 0;
  2537. //
  2538. // case WM_SIZE:
  2539. // if (message == WM_SIZE)
  2540. // {
  2541. // cxClient = LOWORD(lParam);
  2542. // cyClient = HIWORD(lParam);
  2543. // }
  2544. //
  2545. // rectScroll.left = 0;
  2546. // rectScroll.right = cxClient;
  2547. // rectScroll.top = cyChar;
  2548. // rectScroll.bottom = cyChar * (cyClient / cyChar);
  2549. // InvalidateRect(hwnd, NULL, TRUE);
  2550. // return 0;
  2551. //
  2552. // case WM_KEYDOWN:
  2553. // case WM_KEYUP:
  2554. // case WM_CHAR:
  2555. // case WM_DEADCHAR:
  2556. // case WM_SYSKEYDOWN:
  2557. // case WM_SYSKEYUP:
  2558. // case WM_SYSCHAR:
  2559. // case WM_SYSDEADCHAR:
  2560. // for (i = cLinesMax - 1; i > 0; i--)
  2561. // {
  2562. // pmsg[i] = pmsg[i - 1];
  2563. // }
  2564. // pmsg[0].hwnd = hwnd;
  2565. // pmsg[0].message = message;
  2566. // pmsg[0].wParam = wParam;
  2567. // pmsg[0].lParam = lParam;
  2568. //
  2569. // cLines = min(cLines + 1, cLinesMax);
  2570. // ScrollWindow(hwnd, 0, -cyChar, &rectScroll, &rectScroll);
  2571. // break;
  2572. //
  2573. // case WM_PAINT:
  2574. // hdc = BeginPaint(hwnd, &ps);
  2575. // SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
  2576. // SetBkMode(hdc, TRANSPARENT);
  2577. // TextOut(hdc, 0, 0, szTop, lstrlen(szTop));
  2578. // TextOut(hdc, 0, 0, szUnd, lstrlen(szUnd));
  2579. //
  2580. // for (i = 0; i < min(cLines, cyClient / cyChar - 1); i++)
  2581. // {
  2582. // iType = pmsg[i].message == WM_CHAR || pmsg[i].message == WM_SYSCHAR ||
  2583. // pmsg[i].message == WM_DEADCHAR ||
  2584. // pmsg[i].message == WM_SYSDEADCHAR;
  2585. //
  2586. // GetKeyNameText(pmsg[i].lParam, szKeyName, sizeof(szKeyName) / sizeof(TCHAR));
  2587. //
  2588. // TextOut(hdc, 0, (cyClient / cyChar - 1 - i) * cyChar, szBuffer, wsprintf(szBuffer, szFormat[iType],
  2589. // szMessage[pmsg[i].message - WM_KEYFIRST],
  2590. // pmsg[i].wParam,
  2591. // (PTSTR)(iType ? TEXT(" ") : szKeyName),
  2592. // (TCHAR)(iType ? pmsg[i].wParam : ' '),
  2593. // LOWORD(pmsg[i].lParam),
  2594. // HIWORD(pmsg[i].lParam) & 0xFF,
  2595. // 0x01000000 & pmsg[i].lParam ? szYes : szNo,
  2596. // 0x20000000 & pmsg[i].lParam ? szYes : szNo,
  2597. // 0x40000000 & pmsg[i].lParam ? szDown : szUp,
  2598. // 0x80000000 & pmsg[i].lParam ? szUp : szDown));
  2599. // }
  2600. // EndPaint(hwnd, &ps);
  2601. // return 0;
  2602. //
  2603. // case WM_DESTROY:
  2604. // PostQuitMessage(0);
  2605. // return 0;
  2606. // }
  2607. // return DefWindowProc(hwnd, message, wParam, lParam);
  2608. //
  2609. //}
  2610.  
  2611.  
  2612. //SYSMETS4
  2613.  
  2614. //#include<Windows.h>
  2615. //#include "SYSMETS.h"
  2616. //
  2617. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  2618. //
  2619. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  2620. //{
  2621. // static TCHAR szAppName[] = TEXT("SysMets4");
  2622. // HWND hwnd;
  2623. // MSG msg;
  2624. // WNDCLASS wndclass;
  2625. //
  2626. // wndclass.style = CS_HREDRAW || CS_VREDRAW;
  2627. // wndclass.lpfnWndProc = WndProc;
  2628. // wndclass.cbClsExtra = 0;
  2629. // wndclass.cbWndExtra = 0;
  2630. // wndclass.hInstance = hInstance;
  2631. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  2632. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  2633. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  2634. // wndclass.lpszMenuName = NULL;
  2635. // wndclass.lpszClassName = szAppName;
  2636. //
  2637. // if (!RegisterClass(&wndclass))
  2638. // {
  2639. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  2640. // return 0;
  2641. // }
  2642. //
  2643. // hwnd = CreateWindow(szAppName, TEXT("Get System Metrics No.4"), WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  2644. // ShowWindow(hwnd, iCmdShow);
  2645. // UpdateWindow(hwnd);
  2646. //
  2647. // while (GetMessage(&msg, NULL, 0, 0))
  2648. // {
  2649. // TranslateMessage(&msg);
  2650. // DispatchMessage(&msg);
  2651. // }
  2652. // return msg.wParam;
  2653. //
  2654. //}
  2655. //
  2656. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  2657. //{
  2658. // static int cxChar, cxCaps, cyChar, cxClient, cyClient, iMaxWidth;
  2659. // HDC hdc;
  2660. // int i, x, y, iVertPos, iHorzPos, iPaintBeg, iPaintEnd;
  2661. // PAINTSTRUCT ps;
  2662. // SCROLLINFO si;
  2663. // TCHAR szBuffer[10];
  2664. // TEXTMETRIC tm;
  2665. //
  2666. // switch (message)
  2667. // {
  2668. // case WM_CREATE:
  2669. // hdc = GetDC(hwnd);
  2670. // GetTextMetrics(hdc, &tm);
  2671. // cxChar = tm.tmAveCharWidth;
  2672. // cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
  2673. // cyChar = tm.tmHeight + tm.tmExternalLeading;
  2674. //
  2675. // ReleaseDC(hwnd, hdc);
  2676. // iMaxWidth = 40 * cxChar + 22 * cxCaps;
  2677. // return 0;
  2678. //
  2679. // case WM_SIZE:
  2680. // cxClient = LOWORD(lParam);
  2681. // cyClient = HIWORD(lParam);
  2682. //
  2683. // si.cbSize = sizeof(si);
  2684. // si.fMask = SIF_RANGE | SIF_PAGE;
  2685. // si.nMin = 0;
  2686. // si.nMax = NUMLINES - 1;
  2687. // si.nPage = cyClient / cyChar;
  2688. //
  2689. // SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
  2690. // return 0;
  2691. //
  2692. // case WM_VSCROLL:
  2693. // si.cbSize = sizeof(si);
  2694. // si.fMask = SIF_ALL;
  2695. // GetScrollInfo(hwnd, SB_VERT, &si);
  2696. //
  2697. // iVertPos = si.nPos;
  2698. //
  2699. // switch (LOWORD(wParam))
  2700. // {
  2701. // case SB_TOP:
  2702. // si.nPos = si.nMin;
  2703. // break;
  2704. //
  2705. // case SB_BOTTOM:
  2706. // si.nPos = si.nMax;
  2707. // break;
  2708. //
  2709. // case SB_LINEUP:
  2710. // si.nPos -= 1;
  2711. // break;
  2712. //
  2713. // case SB_PAGEUP:
  2714. // si.nPos -= si.nPage;
  2715. // break;
  2716. //
  2717. // case SB_PAGEDOWN:
  2718. // si.nPos += si.nPage;
  2719. // break;
  2720. //
  2721. // case SB_THUMBTRACK:
  2722. // si.nPos = si.nTrackPos;
  2723. // break;
  2724. //
  2725. // default:
  2726. // break;
  2727. // }
  2728. //
  2729. // si.fMask = SIF_POS;
  2730. // SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
  2731. // GetScrollInfo(hwnd, SB_VERT, &si);
  2732. //
  2733. // if (si.nPos != iVertPos)
  2734. // {
  2735. // ScrollWindow(hwnd, 0, cyChar * (iVertPos - si.nPos), NULL, NULL);
  2736. // UpdateWindow(hwnd);
  2737. // }
  2738. // return 0;
  2739. //
  2740. // case WM_HSCROLL:
  2741. // si.cbSize = sizeof(si);
  2742. // si.fMask = SIF_ALL;
  2743. // GetScrollInfo(hwnd, SB_HORZ, &si);
  2744. // iHorzPos = si.nPos;
  2745. //
  2746. // switch (LOWORD(wParam))
  2747. // {
  2748. // case SB_LINELEFT:
  2749. // si.nPos -= 1;
  2750. // break;
  2751. //
  2752. // case SB_LINERIGHT:
  2753. // si.nPos += 1;
  2754. // break;
  2755. //
  2756. // case SB_PAGELEFT:
  2757. // si.nPos -= si.nPage;
  2758. // break;
  2759. //
  2760. // case SB_PAGERIGHT:
  2761. // si.nPos += si.nPage;
  2762. // break;
  2763. //
  2764. // case SB_THUMBPOSITION:
  2765. // si.nPos = si.nTrackPos;
  2766. // break;
  2767. //
  2768. // default:
  2769. // break;
  2770. //
  2771. // }
  2772. //
  2773. // si.fMask = SIF_POS;
  2774. // SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
  2775. // GetScrollInfo(hwnd, SB_HORZ, &si);
  2776. //
  2777. // if (si.nPos != iHorzPos)
  2778. // {
  2779. // ScrollWindow(hwnd, cxChar * (iHorzPos - si.nPos), 0, NULL, NULL);
  2780. // }
  2781. // return 0;
  2782. //
  2783. // case WM_KEYDOWN:
  2784. // switch (wParam)
  2785. // {
  2786. // case VK_HOME:
  2787. // SendMessage(hwnd, WM_HSCROLL, SB_TOP, 0);
  2788. // break;
  2789. //
  2790. // case VK_END:
  2791. // SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, 0);
  2792. // break;
  2793. //
  2794. // case VK_PRIOR:
  2795. // SendMessage(hwnd, WM_VSCROLL, SB_PAGEUP, 0);
  2796. // break;
  2797. //
  2798. // case VK_NEXT:
  2799. // SendMessage(hwnd, WM_VSCROLL, SB_PAGEDOWN, 0);
  2800. // break;
  2801. //
  2802. // case VK_UP:
  2803. // SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0);
  2804. // break;
  2805. //
  2806. // case VK_DOWN:
  2807. // SendMessage(hwnd, WM_VSCROLL, SB_LINEDOWN, 0);
  2808. // break;
  2809. //
  2810. // case VK_LEFT:
  2811. // SendMessage(hwnd, WM_HSCROLL, SB_PAGEUP, 0);
  2812. // break;
  2813. //
  2814. // case VK_RIGHT:
  2815. // SendMessage(hwnd, WM_HSCROLL, SB_PAGEDOWN, 0);
  2816. // break;
  2817. // }
  2818. // return 0;
  2819. //
  2820. // case WM_PAINT:
  2821. // hdc = BeginPaint(hwnd, &ps);
  2822. // si.cbSize = sizeof(si);
  2823. // si.fMask = SIF_POS;
  2824. // GetScrollInfo(hwnd, SB_VERT, &si);
  2825. // iVertPos = si.nPos;
  2826. // GetScrollInfo(hwnd, SB_HORZ, &si);
  2827. // iHorzPos = si.nPos;
  2828. // iPaintBeg = max(0, iVertPos + ps.rcPaint.top / cyChar);
  2829. // iPaintEnd = min(NUMLINES - 1, iVertPos + ps.rcPaint.bottom / cyChar);
  2830. //
  2831. // for (i = iPaintBeg; i < iPaintEnd; i++)
  2832. // {
  2833. // x = cxChar * (1 - iHorzPos);
  2834. // y = cyChar * (i - iVertPos);
  2835. //
  2836. // TextOut(hdc, x, y, sysmetrics[i].szLabel, lstrlen(sysmetrics[i].szLabel));
  2837. // TextOut(hdc, x + 22 * cxCaps, y, sysmetrics[i].szDesc, lstrlen(sysmetrics[i].szDesc));
  2838. // SetTextAlign(hdc, TA_RIGHT | TA_TOP);
  2839. // TextOut(hdc, x + 22 * cxCaps + 40 * cxChar, y, szBuffer, wsprintf(szBuffer, TEXT("%5d"), GetSystemMetrics(sysmetrics[i].iIndex)));
  2840. // SetTextAlign(hdc, TA_LEFT | TA_TOP);
  2841. // }
  2842. // EndPaint(hwnd, &ps);
  2843. // return 0;
  2844. //
  2845. // case WM_DESTROY:
  2846. // PostQuitMessage(0);
  2847. // return 0;
  2848. // }
  2849. // return DefWindowProc(hwnd, message, wParam, lParam);
  2850. //
  2851. //}
  2852.  
  2853.  
  2854. //CLOVER
  2855.  
  2856. //#include<windows.h>
  2857. //#include<math.h>
  2858. //
  2859. //#define TWO_PI (2.0 * 3.14159)
  2860. //
  2861. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  2862. //
  2863. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  2864. //{
  2865. // static TCHAR szAppName[] = TEXT("Clover");
  2866. // HWND hwnd;
  2867. // MSG msg;
  2868. // WNDCLASS wndclass;
  2869. //
  2870. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  2871. // wndclass.lpfnWndProc = WndProc;
  2872. // wndclass.cbClsExtra = 0;
  2873. // wndclass.cbWndExtra = 0;
  2874. // wndclass.hInstance = hInstance;
  2875. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  2876. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  2877. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  2878. // wndclass.lpszMenuName = NULL;
  2879. // wndclass.lpszClassName = szAppName;
  2880. //
  2881. // if (!RegisterClass(&wndclass))
  2882. // {
  2883. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  2884. // return 0;
  2885. // }
  2886. //
  2887. // hwnd = CreateWindow(szAppName, TEXT("Draw a Clover"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  2888. // ShowWindow(hwnd, iCmdShow);
  2889. // UpdateWindow(hwnd);
  2890. //
  2891. // while (GetMessage(&msg, NULL, 0, 0))
  2892. // {
  2893. // TranslateMessage(&msg);
  2894. // DispatchMessage(&msg);
  2895. // }
  2896. // return msg.wParam;
  2897. //
  2898. //}
  2899. //
  2900. //LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
  2901. //{
  2902. // static HRGN hRgnClip;
  2903. // static int cxClient, cyClient;
  2904. // double fAngle, fRadius;
  2905. // HCURSOR hCursor;
  2906. // HDC hdc;
  2907. // HRGN hRgnTemp[6];
  2908. // int i;
  2909. // PAINTSTRUCT ps;
  2910. //
  2911. // switch (iMsg)
  2912. // {
  2913. // case WM_SIZE:
  2914. // cxClient = LOWORD(lParam);
  2915. // cyClient = HIWORD(lParam);
  2916. // hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2917. // ShowCursor(TRUE);
  2918. //
  2919. // if (hRgnClip) DeleteObject(hRgnClip);
  2920. // hRgnTemp[0] = CreateEllipticRgn(0, cyClient / 3, cxClient / 2, 2 * cyClient / 3);
  2921. // hRgnTemp[1] = CreateEllipticRgn(cxClient / 2, cyClient / 3, cxClient, 2 * cyClient / 3);
  2922. // hRgnTemp[2] = CreateEllipticRgn(cxClient / 3, 0, 2 * cxClient / 3, cyClient / 2);
  2923. // hRgnTemp[3] = CreateEllipticRgn(cxClient / 3, cyClient / 2, 2 * cxClient / 3, cyClient);
  2924. //
  2925. // hRgnTemp[4] = CreateRectRgn(0, 0, 1, 1);
  2926. // hRgnTemp[5] = CreateRectRgn(0, 0, 1, 1);
  2927. // hRgnClip = CreateRectRgn(0, 0, 1, 1);
  2928. //
  2929. // CombineRgn(hRgnTemp[4], hRgnTemp[0], hRgnTemp[1], RGN_OR);
  2930. // CombineRgn(hRgnTemp[5], hRgnTemp[2], hRgnTemp[3], RGN_OR);
  2931. // CombineRgn(hRgnClip, hRgnTemp[4], hRgnTemp[5], RGN_XOR);
  2932. //
  2933. // for (i = 0; i < 6; i++)
  2934. // {
  2935. // DeleteObject(hRgnTemp[i]);
  2936. // }
  2937. // SetCursor(hCursor);
  2938. // ShowCursor(FALSE);
  2939. // return 0;
  2940. //
  2941. // case WM_PAINT:
  2942. // hdc = BeginPaint(hwnd, &ps);
  2943. // SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);
  2944. // SelectClipRgn(hdc, hRgnClip);
  2945. // fRadius = _hypot(cxClient / 2.0, cyClient / 2.0);
  2946. // for (fAngle = 0.0; fAngle < TWO_PI; fAngle += TWO_PI / 360);
  2947. // {
  2948. // MoveToEx(hdc, 0, 0, NULL);
  2949. // LineTo(hdc, (int) (fRadius * cos(fAngle) + 0.5), (int) (-fRadius * sin(fAngle) + 0.5));
  2950. // }
  2951. // EndPaint(hwnd, &ps);
  2952. // return 0;
  2953. //
  2954. // case WM_DESTROY:
  2955. // DeleteObject(hRgnClip);
  2956. // PostQuitMessage(0);
  2957. // return 0;
  2958. //
  2959. // }
  2960. //
  2961. // return DefWindowProc(hwnd, iMsg, wParam, lParam);
  2962. //
  2963. //}
  2964.  
  2965.  
  2966. //RANDRECT
  2967.  
  2968. //#include<Windows.h>
  2969. //#include<stdlib.h>
  2970. //
  2971. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  2972. //void DrawRectangle(HWND);
  2973. //
  2974. //int cxClient, cyClient;
  2975. //
  2976. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  2977. //{
  2978. // static TCHAR szAppname[] = TEXT("RandRect");
  2979. // HWND hwnd;
  2980. // MSG msg;
  2981. // WNDCLASS wndclass;
  2982. //
  2983. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  2984. // wndclass.lpfnWndProc = WndProc;
  2985. // wndclass.cbClsExtra = 0;
  2986. // wndclass.cbWndExtra = 0;
  2987. // wndclass.hInstance = hInstance;
  2988. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  2989. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  2990. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  2991. // wndclass.lpszMenuName = NULL;
  2992. // wndclass.lpszClassName = szAppname;
  2993. //
  2994. // if (!RegisterClass(&wndclass))
  2995. // {
  2996. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppname, MB_ICONERROR);
  2997. // return 0;
  2998. // }
  2999. //
  3000. // hwnd = CreateWindow(szAppname, TEXT("Random Rectangles"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3001. // ShowWindow(hwnd, iCmdShow);
  3002. // UpdateWindow(hwnd);
  3003. //
  3004. // while (TRUE)
  3005. // {
  3006. // if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  3007. // {
  3008. // if (msg.message == WM_QUIT)
  3009. // {
  3010. // break;
  3011. // }
  3012. // TranslateMessage(&msg);
  3013. // DispatchMessage(&msg);
  3014. // }
  3015. // else
  3016. // {
  3017. // DrawRectangle(hwnd);
  3018. // }
  3019. // return msg.wParam;
  3020. // }
  3021. //}
  3022. //
  3023. //LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
  3024. //{
  3025. // switch (iMsg)
  3026. // {
  3027. // case WM_SIZE:
  3028. // cxClient = LOWORD(lParam);
  3029. // cyClient = HIWORD(lParam);
  3030. // return 0;
  3031. //
  3032. // case WM_DESTROY:
  3033. // PostQuitMessage(0);
  3034. // return 0;
  3035. // }
  3036. // return DefWindowProc(hwnd, iMsg, wParam, lParam);
  3037. //
  3038. //}
  3039. //
  3040. //void DrawRectangle(HWND hwnd)
  3041. //{
  3042. // HBRUSH hBrush;
  3043. // HDC hdc;
  3044. // RECT rect;
  3045. //
  3046. // if (cxClient == 0 || cyClient == 0) return ;
  3047. // SetRect(&rect, rand() % cxClient, rand() % cyClient, rand() % cxClient, rand() % cyClient);
  3048. // hBrush = CreateSolidBrush(RGB(rand() % 256, rand() % 256, rand() % 256));
  3049. // hdc = GetDC(hwnd);
  3050. // FillRect(hdc, &rect, hBrush);
  3051. // ReleaseDC(hwnd, hdc);
  3052. // DeleteObject(hBrush);
  3053. //}
  3054.  
  3055.  
  3056. //WHATSIZE
  3057.  
  3058. //#include<Windows.h>
  3059. //
  3060. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3061. //
  3062. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3063. //{
  3064. // static TCHAR szAppName[] = TEXT("WhatSize");
  3065. // HWND hwnd;
  3066. // MSG msg;
  3067. // WNDCLASS wndclass;
  3068. //
  3069. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3070. // wndclass.lpfnWndProc = WndProc;
  3071. // wndclass.cbClsExtra = 0;
  3072. // wndclass.cbWndExtra = 0;
  3073. // wndclass.hInstance = hInstance;
  3074. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3075. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3076. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3077. // wndclass.lpszMenuName = NULL;
  3078. // wndclass.lpszClassName = szAppName;
  3079. //
  3080. // if (!RegisterClass(&wndclass))
  3081. // {
  3082. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  3083. // return 0;
  3084. // }
  3085. //
  3086. // hwnd = CreateWindow(szAppName, TEXT("What Size is the Window?"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3087. // ShowWindow(hwnd, iCmdShow);
  3088. // UpdateWindow(hwnd);
  3089. //
  3090. // while (GetMessage(&msg, NULL, 0, 0))
  3091. // {
  3092. // TranslateMessage(&msg);
  3093. // DispatchMessage(&msg);
  3094. // }
  3095. // return msg.wParam;
  3096. //
  3097. //}
  3098. //
  3099. //void Show(HWND hwnd, HDC hdc, int xText, int yText, int iMapMode, TCHAR * szMapMode)
  3100. //{
  3101. // TCHAR szBuffer[60];
  3102. // RECT rect;
  3103. //
  3104. // SaveDC(hdc);
  3105. // SetMapMode(hdc, iMapMode);
  3106. // GetClientRect(hwnd, &rect);
  3107. // DPtoLP(hdc, (PPOINT) &rect, 2);
  3108. //
  3109. // RestoreDC(hdc, -1);
  3110. // TextOut(hdc, xText, yText, szBuffer, wsprintf(szBuffer, TEXT("%-20s %7d %7d %7d %7d"), szMapMode, rect.left, rect.right, rect.top, rect.bottom));
  3111. //
  3112. //}
  3113. //
  3114. //
  3115. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3116. //{
  3117. // static TCHAR szHeading[] = TEXT("MappingMode LEFT RIGHT TOP BOTTOM");
  3118. // static TCHAR szUndLine[] = TEXT("----------- ---- ----- --- ------");
  3119. // static int cxChar, cyChar;
  3120. // HDC hdc;
  3121. // PAINTSTRUCT ps;
  3122. // TEXTMETRIC tm;
  3123. //
  3124. // switch (message)
  3125. // {
  3126. // case WM_CREATE:
  3127. // hdc = GetDC(hwnd);
  3128. // SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
  3129. // GetTextMetrics(hdc, &tm);
  3130. // cxChar = tm.tmAveCharWidth;
  3131. // cyChar = tm.tmHeight + tm.tmExternalLeading;
  3132. // ReleaseDC(hwnd, hdc);
  3133. // return 0;
  3134. //
  3135. // case WM_PAINT:
  3136. // hdc = BeginPaint(hwnd, &ps);
  3137. // SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
  3138. // SetMapMode(hdc, MM_ANISOTROPIC);
  3139. // SetWindowExtEx(hdc, 1, 1, NULL);
  3140. // SetViewportExtEx(hdc, cxChar, cyChar, NULL);
  3141. // TextOut(hdc, 1, 1, szHeading, lstrlen(szHeading));
  3142. // TextOut(hdc, 1, 2, szUndLine, lstrlen(szUndLine));
  3143. //
  3144. // Show(hwnd, hdc, 1, 3, MM_TEXT, TEXT("TEXT(pixels)"));
  3145. // Show(hwnd, hdc, 1, 4, MM_LOMETRIC, TEXT("LOMETRIC(.1mm)"));
  3146. // Show(hwnd, hdc, 1, 5, MM_HIMETRIC, TEXT("HIMETRIC(.01 mm)"));
  3147. // Show(hwnd, hdc, 1, 6, MM_LOENGLISH, TEXT("LOENGLISH(.01 in)"));
  3148. // Show(hwnd, hdc, 1, 7, MM_HIENGLISH, TEXT("HIENGLISH(.001 in)"));
  3149. // Show(hwnd, hdc, 1, 8, MM_TWIPS, TEXT("TWIPS(1/1440 in)"));
  3150. //
  3151. // EndPaint(hwnd, &ps);
  3152. // return 0;
  3153. //
  3154. // case WM_DESTROY:
  3155. // PostQuitMessage(0);
  3156. // return 0;
  3157. // }
  3158. // return DefWindowProc(hwnd, message, wParam, lParam);
  3159. //
  3160. //}
  3161.  
  3162.  
  3163. //ALTWIND
  3164.  
  3165. //#include<Windows.h>
  3166. //
  3167. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3168. //
  3169. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3170. //{
  3171. // static TCHAR szAppName[] = TEXT("AltWind");
  3172. // HWND hwnd;
  3173. // MSG msg;
  3174. // WNDCLASS wndclass;
  3175. //
  3176. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3177. // wndclass.lpfnWndProc = WndProc;
  3178. // wndclass.cbClsExtra = 0;
  3179. // wndclass.cbWndExtra = 0;
  3180. // wndclass.hInstance = hInstance;
  3181. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3182. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3183. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3184. // wndclass.lpszMenuName = NULL;
  3185. // wndclass.lpszClassName = szAppName;
  3186. //
  3187. // if (!RegisterClass(&wndclass))
  3188. // {
  3189. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  3190. // return 0;
  3191. // }
  3192. //
  3193. // hwnd = CreateWindow(szAppName, TEXT("Alternate and Winding Fill Modes"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3194. // ShowWindow(hwnd, iCmdShow);
  3195. // UpdateWindow(hwnd);
  3196. //
  3197. // while (GetMessage(&msg, NULL, 0, 0))
  3198. // {
  3199. // TranslateMessage(&msg);
  3200. // DispatchMessage(&msg);
  3201. // }
  3202. // return msg.wParam;
  3203. //
  3204. //}
  3205. //
  3206. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3207. //{
  3208. // static POINT aptFigure[10] = { 10, 70, 50, 70, 50, 10, 90, 10, 90, 50, 30, 50, 30, 90, 70, 90, 70, 30, 10, 30 };
  3209. // static int cxClient, cyClient;
  3210. // HDC hdc;
  3211. // int i;
  3212. // PAINTSTRUCT ps;
  3213. // POINT apt[10];
  3214. //
  3215. // switch (message)
  3216. // {
  3217. // case WM_SIZE:
  3218. // cxClient = LOWORD(lParam);
  3219. // cyClient = HIWORD(lParam);
  3220. // case WM_PAINT:
  3221. // hdc = BeginPaint(hwnd, &ps);
  3222. // SelectObject(hdc, GetStockObject(GRAY_BRUSH));
  3223. // for (i = 0; i < 10; i++)
  3224. // {
  3225. // apt[i].x = cxClient * aptFigure[i].x / 200;
  3226. // apt[i].y = cyClient * aptFigure[i].y / 100;
  3227. // }
  3228. // SetPolyFillMode(hdc, ALTERNATE);
  3229. // Polygon(hdc, apt, 10);
  3230. // for (i = 0; i < 10; i++)
  3231. // {
  3232. // apt[i].x += cxClient / 2;
  3233. // }
  3234. // SetPolyFillMode(hdc, WINDING);
  3235. // Polygon(hdc, apt, 10);
  3236. // EndPaint(hwnd, &ps);
  3237. // return 0;
  3238. // case WM_DESTROY:
  3239. // PostQuitMessage(0);
  3240. // return 0;
  3241. // }
  3242. //
  3243. //
  3244. // return DefWindowProc(hwnd, message, wParam, lParam);
  3245. //}
  3246.  
  3247.  
  3248. //BEZIER
  3249.  
  3250. //#include<Windows.h>
  3251. //
  3252. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3253. //
  3254. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3255. //{
  3256. // static TCHAR szAppName[] = TEXT("Bezier");
  3257. // HWND hwnd;
  3258. // MSG msg;
  3259. // WNDCLASS wndclass;
  3260. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3261. // wndclass.lpfnWndProc = WndProc;
  3262. // wndclass.cbClsExtra = 0;
  3263. // wndclass.cbWndExtra = 0;
  3264. // wndclass.hInstance = hInstance;
  3265. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3266. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3267. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3268. // wndclass.lpszMenuName = NULL;
  3269. // wndclass.lpszClassName = szAppName;
  3270. //
  3271. //
  3272. // if (!RegisterClass(&wndclass))
  3273. // {
  3274. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  3275. // return 0;
  3276. // }
  3277. //
  3278. // hwnd = CreateWindow(szAppName, TEXT("Bezier Splines"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3279. // ShowWindow(hwnd, iCmdShow);
  3280. // UpdateWindow(hwnd);
  3281. //
  3282. // while (GetMessage(&msg, NULL, 0, 0))
  3283. // {
  3284. // TranslateMessage(&msg);
  3285. // DispatchMessage(&msg);
  3286. // }
  3287. //
  3288. // return msg.wParam;
  3289. //}
  3290. //
  3291. //void DrawBezier(HDC hdc, POINT apt[])
  3292. //{
  3293. // PolyBezier(hdc, apt, 4);
  3294. // MoveToEx(hdc, apt[0].x, apt[0].y, NULL);
  3295. // LineTo(hdc, apt[1].x, apt[1].y);
  3296. // MoveToEx(hdc, apt[2].x, apt[2].y, NULL);
  3297. // LineTo(hdc, apt[3].x, apt[3].y);
  3298. //}
  3299. //
  3300. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3301. //{
  3302. // static POINT apt[4];
  3303. // HDC hdc;
  3304. // int cxClient, cyClient;
  3305. // PAINTSTRUCT ps;
  3306. //
  3307. // switch (message)
  3308. // {
  3309. // case WM_SIZE:
  3310. // cxClient = LOWORD(lParam);
  3311. // cyClient = HIWORD(lParam);
  3312. // apt[0].x = cxClient / 4;
  3313. // apt[0].y = cyClient / 2;
  3314. //
  3315. // apt[1].x = cxClient / 2;
  3316. // apt[1].y = cyClient / 4;
  3317. //
  3318. // apt[2].x = cxClient / 2;
  3319. // apt[2].y = 3*cyClient / 4;
  3320. //
  3321. // apt[3].x = 3 * cxClient / 4;
  3322. // apt[3].y = cyClient / 2;
  3323. // return 0;
  3324. //
  3325. // case WM_LBUTTONDOWN:
  3326. // case WM_RBUTTONDOWN:
  3327. // case WM_MOUSEMOVE:
  3328. // if (wParam & MK_LBUTTON || wParam & MK_RBUTTON)
  3329. // {
  3330. // hdc = GetDC(hwnd);
  3331. // SelectObject(hdc, GetStockObject(WHITE_PEN));
  3332. // DrawBezier(hdc, apt);
  3333. // ReleaseDC(hwnd, hdc);
  3334. // }
  3335. // return 0;
  3336. //
  3337. // case WM_PAINT:
  3338. // InvalidateRect(hwnd, NULL, TRUE);
  3339. // hdc = BeginPaint(hwnd, &ps);
  3340. // DrawBezier(hdc, apt);
  3341. // EndPaint(hwnd, &ps);
  3342. // return 0;
  3343. //
  3344. // case WM_DESTROY:
  3345. // PostQuitMessage(0);
  3346. // return 0;
  3347. // }
  3348. //
  3349. // return DefWindowProc(hwnd, message, wParam, lParam);
  3350. //}
  3351.  
  3352.  
  3353. //LINEDEMO
  3354.  
  3355. //#include<Windows.h>
  3356. //
  3357. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3358. //
  3359. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3360. //{
  3361. // static TCHAR szAppName[] = TEXT("LineDemo");
  3362. // HWND hwnd;
  3363. // MSG msg;
  3364. // WNDCLASS wndclass;
  3365. //
  3366. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3367. // wndclass.lpfnWndProc = WndProc;
  3368. // wndclass.cbClsExtra = 0;
  3369. // wndclass.cbWndExtra = 0;
  3370. // wndclass.hInstance = hInstance;
  3371. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3372. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3373. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3374. // wndclass.lpszMenuName = NULL;
  3375. // wndclass.lpszClassName = szAppName;
  3376. //
  3377. //
  3378. // if (!RegisterClass(&wndclass))
  3379. // {
  3380. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  3381. // return 0;
  3382. // }
  3383. //
  3384. // hwnd = CreateWindow(szAppName, TEXT("Line Demonstration"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3385. // ShowWindow(hwnd, iCmdShow);
  3386. // UpdateWindow(hwnd);
  3387. //
  3388. // while (GetMessage(&msg, NULL, 0, 0))
  3389. // {
  3390. // TranslateMessage(&msg);
  3391. // DispatchMessage(&msg);
  3392. // }
  3393. // return msg.wParam;
  3394. //}
  3395. //
  3396. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3397. //{
  3398. // static int cxClient, cyClient;
  3399. // HDC hdc;
  3400. // PAINTSTRUCT ps;
  3401. //
  3402. // switch (message)
  3403. // {
  3404. // case WM_SIZE:
  3405. // cxClient = LOWORD(lParam);
  3406. // cyClient = HIWORD(lParam);
  3407. // return 0;
  3408. // case WM_PAINT:
  3409. // hdc = BeginPaint(hwnd, &ps);
  3410. // Rectangle(hdc, cxClient / 8, cyClient / 8, 7 * cxClient / 8, 7 * cyClient / 8);
  3411. // MoveToEx(hdc, 0, 0, NULL);
  3412. // LineTo(hdc, cxClient, cyClient);
  3413. // MoveToEx(hdc, 0, cyClient, NULL);
  3414. // LineTo(hdc, cxClient, 0);
  3415. // Ellipse(hdc, cxClient / 8, cyClient / 8, 7 * cxClient / 8, 7 * cyClient / 8);
  3416. // RoundRect(hdc, cxClient / 4, cyClient / 4, 3 * cxClient / 4, 3 * cyClient / 4, cxClient / 4, cyClient / 4);
  3417. // EndPaint(hwnd, &ps);
  3418. // return 0;
  3419. // case WM_DESTROY:
  3420. // PostQuitMessage(0);
  3421. // return 0;
  3422. // }
  3423. //
  3424. // return DefWindowProc(hwnd, message, wParam, lParam);
  3425. //}
  3426.  
  3427.  
  3428. //SINEWAVE
  3429.  
  3430. //#include<Windows.h>
  3431. //#include<math.h>
  3432. //
  3433. //#define NUM 1000
  3434. //#define TWOPI (2*3.14159)
  3435. //
  3436. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3437. //
  3438. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3439. //{
  3440. // static TCHAR szAppName[] = TEXT("SineWave");
  3441. // HWND hwnd;
  3442. // MSG msg;
  3443. // WNDCLASS wndclass;
  3444. //
  3445. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3446. // wndclass.lpfnWndProc = WndProc;
  3447. // wndclass.cbClsExtra = 0;
  3448. // wndclass.cbWndExtra = 0;
  3449. // wndclass.hInstance = hInstance;
  3450. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3451. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3452. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3453. // wndclass.lpszMenuName = NULL;
  3454. // wndclass.lpszClassName = szAppName;
  3455. //
  3456. // if (!RegisterClass(&wndclass))
  3457. // {
  3458. // MessageBox(NULL, TEXT("Program requires Windows NT!"), szAppName, MB_ICONERROR);
  3459. // return 0;
  3460. // }
  3461. //
  3462. // hwnd = CreateWindow(szAppName, TEXT("Sine Wave Using Polyline"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3463. // ShowWindow(hwnd, iCmdShow);
  3464. // UpdateWindow(hwnd);
  3465. //
  3466. // while (GetMessage(&msg, NULL, 0, 0))
  3467. // {
  3468. // TranslateMessage(&msg);
  3469. // DispatchMessage(&msg);
  3470. // }
  3471. // return msg.wParam;
  3472. //
  3473. //}
  3474. //
  3475. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3476. //{
  3477. // static int cxClient, cyClient;
  3478. // HDC hdc;
  3479. // int i;
  3480. // PAINTSTRUCT ps;
  3481. // POINT apt[NUM];
  3482. //
  3483. // switch (message)
  3484. // {
  3485. // case WM_SIZE:
  3486. // cxClient = LOWORD(lParam);
  3487. // cyClient = HIWORD(lParam);
  3488. // return 0;
  3489. //
  3490. // case WM_PAINT:
  3491. // hdc = BeginPaint(hwnd, &ps);
  3492. // MoveToEx(hdc, 0, cyClient / 2, NULL);
  3493. // LineTo(hdc, cxClient, cyClient / 2);
  3494. // for (i = 0; i < NUM; i++)
  3495. // {
  3496. // apt[i].x = i*cxClient / NUM;
  3497. // apt[i].y = (int)(cyClient / 2 * (1 - sin(TWOPI*i / NUM)));
  3498. // }
  3499. // Polyline(hdc, apt, NUM);
  3500. // return 0;
  3501. //
  3502. // case WM_DESTROY:
  3503. // PostQuitMessage(0);
  3504. // return 0;
  3505. // }
  3506. //
  3507. // return DefWindowProc(hwnd, message, wParam, lParam);
  3508. //}
  3509.  
  3510.  
  3511. //DEVCAPS1
  3512.  
  3513. //#include<windows.h>
  3514. //#define NUMLINES (int)(sizeof devcaps / sizeof(devcaps[0]) )
  3515. //
  3516. //struct
  3517. //{
  3518. // int iIndex;
  3519. // TCHAR * szLabel;
  3520. // TCHAR * szDesc;
  3521. //}
  3522. //devcaps[] =
  3523. //{
  3524. // HORZSIZE, TEXT("HORZSIZE"), TEXT("Width in millimeters:"),
  3525. // VERTSIZE, TEXT("VERTSIZE"), TEXT("Height in millimeters:"),
  3526. // HORZRES, TEXT("HORZRES"), TEXT("Width in pixels:"),
  3527. // VERTRES, TEXT("VERTRES"), TEXT("Height in raster lines:"),
  3528. // BITSPIXEL, TEXT("BITSPIXEL"), TEXT("Color bits per pixel:"),
  3529. // PLANES, TEXT("PLANES"), TEXT("Number of color planes:"),
  3530. // NUMBRUSHES, TEXT("NUMBRUSHES"), TEXT("Number of device brushes:"),
  3531. // NUMPENS, TEXT("NUMPENS"), TEXT("Number of device pens:"),
  3532. // NUMMARKERS, TEXT("NUMMARKERS"), TEXT("Number of device markers:"),
  3533. // NUMFONTS, TEXT("NUMFONTS"), TEXT("Number of device fonts:"),
  3534. // NUMCOLORS, TEXT("NUMCOLORS"), TEXT("Number of device colors:"),
  3535. // PDEVICESIZE, TEXT("PDEVICESIZE"), TEXT("Size of device structure:"),
  3536. // ASPECTX, TEXT("ASPECTX"), TEXT("Relative width of pixel:"),
  3537. // ASPECTY, TEXT("ASPECTY"), TEXT("Relative height of pixel:"),
  3538. // ASPECTXY, TEXT("ASPECTXY"), TEXT("Relative diagonal of pixel:"),
  3539. // LOGPIXELSX, TEXT("LOGPIXELSX"), TEXT("Horizontal dots per inch:"),
  3540. // LOGPIXELSY, TEXT("LOGPIXELSY"), TEXT("Vertical dots per inch:"),
  3541. // SIZEPALETTE, TEXT("SIZEPALETTE"), TEXT("Number of palette entries:"),
  3542. // NUMRESERVED, TEXT("NUMRESERVED"), TEXT("Reserved palette entries:"),
  3543. // COLORRES, TEXT("COLORRES"), TEXT("Actual color resolution:")
  3544. //};
  3545. //
  3546. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3547. //
  3548. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3549. //{
  3550. // static TCHAR szAppName[] = TEXT("DevCaps1");
  3551. // HWND hwnd;
  3552. // MSG msg;
  3553. // WNDCLASS wndclass;
  3554. //
  3555. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3556. // wndclass.lpfnWndProc = WndProc;
  3557. // wndclass.cbClsExtra = 0;
  3558. // wndclass.cbWndExtra = 0;
  3559. // wndclass.hInstance = hInstance;
  3560. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3561. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3562. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3563. // wndclass.lpszMenuName = NULL;
  3564. // wndclass.lpszClassName = szAppName;
  3565. //
  3566. // if (!RegisterClass(&wndclass))
  3567. // {
  3568. // MessageBox(NULL, TEXT("This program reuqires Windows NT!"), szAppName, MB_ICONERROR);
  3569. // return 0;
  3570. // }
  3571. //
  3572. // hwnd = CreateWindow(szAppName, TEXT("Device Capabilities"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3573. // ShowWindow(hwnd, iCmdShow);
  3574. // UpdateWindow(hwnd);
  3575. //
  3576. // while (GetMessage(&msg, NULL, 0, 0))
  3577. // {
  3578. // TranslateMessage(&msg);
  3579. // DispatchMessage(&msg);
  3580. // }
  3581. // return msg.wParam;
  3582. //
  3583. //}
  3584. //
  3585. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3586. //{
  3587. // static int cxChar, cxCaps, cyChar;
  3588. // TCHAR szBuffer[10];
  3589. // HDC hdc;
  3590. // int i;
  3591. // PAINTSTRUCT ps;
  3592. // TEXTMETRIC tm;
  3593. //
  3594. // switch (message)
  3595. // {
  3596. // case WM_CREATE:
  3597. // hdc = GetDC(hwnd);
  3598. // GetTextMetrics(hdc, &tm);
  3599. // cxChar = tm.tmAveCharWidth;
  3600. // cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
  3601. // cyChar = tm.tmHeight + tm.tmExternalLeading;
  3602. // ReleaseDC(hwnd, hdc);
  3603. // return 0;
  3604. //
  3605. // case WM_PAINT:
  3606. // hdc = BeginPaint(hwnd, &ps);
  3607. // for (i = 0; i < NUMLINES; i++)
  3608. // {
  3609. // TextOut(hdc, 0, cyChar * i, devcaps[i].szLabel,lstrlen(devcaps[i].szLabel));
  3610. // TextOut(hdc, 14 * cxCaps, cyChar * i, devcaps[i].szDesc, lstrlen(devcaps[i].szDesc));
  3611. // SetTextAlign(hdc, TA_RIGHT | TA_TOP);
  3612. // TextOut(hdc, 14 * cxCaps + 35 * cxChar, cyChar * i, szBuffer, wsprintf(szBuffer, TEXT("%5d"), GetDeviceCaps(hdc, devcaps[i].iIndex)));
  3613. // SetTextAlign(hdc, TA_LEFT | TA_TOP);
  3614. // }
  3615. // EndPaint(hwnd, &ps);
  3616. // return 0;
  3617. //
  3618. // case WM_DESTROY:
  3619. // PostQuitMessage(0);
  3620. // return 0;
  3621. // }
  3622. // return DefWindowProc(hwnd, message, wParam, lParam);
  3623. //}
  3624.  
  3625.  
  3626. //SYSMETS3
  3627.  
  3628. //#include <windows.h>
  3629. //#include "SYSMETS.h"
  3630. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3631. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  3632. // PSTR szCmdLine, int iCmdShow)
  3633. //{
  3634. // static TCHAR szAppName[] = TEXT("SysMets3");
  3635. // HWND hwnd;
  3636. // MSG msg;
  3637. // WNDCLASS wndclass;
  3638. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3639. // wndclass.lpfnWndProc = WndProc;
  3640. // wndclass.cbClsExtra = 0;
  3641. // wndclass.cbWndExtra = 0;
  3642. // wndclass.hInstance = hInstance;
  3643. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3644. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3645. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3646. // wndclass.lpszMenuName = NULL;
  3647. // wndclass.lpszClassName = szAppName;
  3648. // if (!RegisterClass(&wndclass))
  3649. // {
  3650. // MessageBox(NULL, TEXT("Program requires Windows NT!"),
  3651. // szAppName, MB_ICONERROR);
  3652. // return 0;
  3653. // }
  3654. // hwnd = CreateWindow(szAppName, TEXT("Get System Metrics No. 3"),
  3655. // WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL,
  3656. // CW_USEDEFAULT, CW_USEDEFAULT,
  3657. // CW_USEDEFAULT, CW_USEDEFAULT,
  3658. // NULL, NULL, hInstance, NULL);
  3659. // ShowWindow(hwnd, iCmdShow);
  3660. // UpdateWindow(hwnd);
  3661. // while (GetMessage(&msg, NULL, 0, 0))
  3662. // {
  3663. // TranslateMessage(&msg);
  3664. // DispatchMessage(&msg);
  3665. // }
  3666. // return msg.wParam;
  3667. //}
  3668. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3669. //{
  3670. // static int cxChar, cxCaps, cyChar, cxClient, cyClient, iMaxWidth;
  3671. // HDC hdc;
  3672. // int i, x, y, iVertPos, iHorzPos, iPaintBeg, iPaintEnd;
  3673. // PAINTSTRUCT ps;
  3674. // SCROLLINFO si;
  3675. // TCHAR szBuffer[10];
  3676. // TEXTMETRIC tm;
  3677. // switch (message)
  3678. // {
  3679. // case WM_CREATE:
  3680. // hdc = GetDC(hwnd);
  3681. // GetTextMetrics(hdc, &tm);
  3682. // cxChar = tm.tmAveCharWidth;
  3683. // cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
  3684. // cyChar = tm.tmHeight + tm.tmExternalLeading;
  3685. // ReleaseDC(hwnd, hdc);
  3686. // iMaxWidth = 40 * cxChar + 22 * cxCaps;
  3687. // return 0;
  3688. // case WM_SIZE:
  3689. // cxClient = LOWORD(lParam);
  3690. // cyClient = HIWORD(lParam);
  3691. // si.cbSize = sizeof(si);
  3692. // si.fMask = SIF_RANGE | SIF_PAGE;
  3693. // si.nMin = 0;
  3694. // si.nMax = NUMLINES - 1;
  3695. // si.nPage = cyClient / cyChar;
  3696. // SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
  3697. // si.cbSize = sizeof(si);
  3698. // si.fMask = SIF_RANGE | SIF_PAGE;
  3699. // si.nMin = 0;
  3700. // si.nMax = 2 + iMaxWidth / cxChar;
  3701. // si.nPage = cxClient / cxChar;
  3702. // SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
  3703. // return 0;
  3704. // case WM_VSCROLL:
  3705. // si.cbSize = sizeof(si);
  3706. // si.fMask = SIF_ALL;
  3707. // GetScrollInfo(hwnd, SB_VERT, &si);
  3708. // iVertPos = si.nPos;
  3709. // switch (LOWORD(wParam))
  3710. // {
  3711. // case SB_TOP:
  3712. // si.nPos = si.nMin;
  3713. // break;
  3714. // case SB_BOTTOM:
  3715. // si.nPos = si.nMax;
  3716. // break;
  3717. // case SB_LINEUP:
  3718. // si.nPos -= 1;
  3719. // break;
  3720. // case SB_LINEDOWN:
  3721. // si.nPos += 1;
  3722. // break;
  3723. // case SB_PAGEUP:
  3724. // si.nPos -= si.nPage;
  3725. // break;
  3726. // case SB_PAGEDOWN:
  3727. // si.nPos += si.nPage;
  3728. // break;
  3729. // case SB_THUMBTRACK:
  3730. // si.nPos = si.nTrackPos;
  3731. // break;
  3732. // default:
  3733. // break;
  3734. // }
  3735. // si.fMask = SIF_POS;
  3736. // SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
  3737. // GetScrollInfo(hwnd, SB_VERT, &si);
  3738. // if (si.nPos != iVertPos)
  3739. // {
  3740. // ScrollWindow(hwnd, 0, cyChar * (iVertPos - si.nPos),
  3741. // NULL, NULL);
  3742. // UpdateWindow(hwnd);
  3743. // }
  3744. // return 0;
  3745. // case WM_HSCROLL:
  3746. // si.cbSize = sizeof(si);
  3747. // si.fMask = SIF_ALL;
  3748. // GetScrollInfo(hwnd, SB_HORZ, &si);
  3749. // iHorzPos = si.nPos;
  3750. // switch (LOWORD(wParam))
  3751. // {
  3752. // case SB_LINELEFT:
  3753. // si.nPos -= 1;
  3754. // break;
  3755. // case SB_LINERIGHT:
  3756. // si.nPos += 1;
  3757. // break;
  3758. // case SB_PAGELEFT:
  3759. // si.nPos -= si.nPage;
  3760. // break;
  3761. // case SB_PAGERIGHT:
  3762. // si.nPos += si.nPage;
  3763. // break;
  3764. // case SB_THUMBPOSITION:
  3765. // si.nPos = si.nTrackPos;
  3766. // break;
  3767. // default:
  3768. // break;
  3769. // }
  3770. //
  3771. // si.fMask = SIF_POS;
  3772. // SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
  3773. // GetScrollInfo(hwnd, SB_HORZ, &si);
  3774. // if (si.nPos != iHorzPos)
  3775. // {
  3776. // ScrollWindow(hwnd, cxChar * (iHorzPos - si.nPos), 0,
  3777. // NULL, NULL);
  3778. // }
  3779. // return 0;
  3780. // case WM_PAINT:
  3781. // hdc = BeginPaint(hwnd, &ps);
  3782. // si.cbSize = sizeof(si);
  3783. // si.fMask = SIF_POS;
  3784. // GetScrollInfo(hwnd, SB_VERT, &si);
  3785. // iVertPos = si.nPos;
  3786. // GetScrollInfo(hwnd, SB_HORZ, &si);
  3787. // iHorzPos = si.nPos;
  3788. // iPaintBeg = max(0, iVertPos + ps.rcPaint.top / cyChar);
  3789. // iPaintEnd = min(NUMLINES - 1,iVertPos + ps.rcPaint.bottom / cyChar);
  3790. // for (i = iPaintBeg; i <= iPaintEnd; i++)
  3791. // {
  3792. // x = cxChar * (1 - iHorzPos);
  3793. // y = cyChar * (i - iVertPos);
  3794. // TextOut(hdc, x, y,
  3795. // sysmetrics[i].szLabel,
  3796. // lstrlen(sysmetrics[i].szLabel));
  3797. // TextOut(hdc, x + 22 * cxCaps, y,
  3798. // sysmetrics[i].szDesc,
  3799. // lstrlen(sysmetrics[i].szDesc));
  3800. // SetTextAlign(hdc, TA_RIGHT | TA_TOP);
  3801. // TextOut(hdc, x + 22 * cxCaps + 40 * cxChar, y, szBuffer,
  3802. // wsprintf(szBuffer, TEXT("%5d"),
  3803. // GetSystemMetrics(sysmetrics[i].iIndex)));
  3804. // SetTextAlign(hdc, TA_LEFT | TA_TOP);
  3805. // }
  3806. // EndPaint(hwnd, &ps);
  3807. // return 0;
  3808. // case WM_DESTROY:
  3809. // PostQuitMessage(0);
  3810. // return 0;
  3811. // }
  3812. // return DefWindowProc(hwnd, message, wParam, lParam);
  3813. //}
  3814.  
  3815.  
  3816. //SYSMETS2
  3817.  
  3818. //#include<Windows.h>
  3819. //#include "SYSMETS.h"
  3820. //
  3821. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3822. //
  3823. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3824. //{
  3825. // static TCHAR szAppName[] = TEXT("SysMets2");
  3826. // HWND hwnd;
  3827. // MSG msg;
  3828. // WNDCLASS wndclass;
  3829. //
  3830. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3831. // wndclass.lpfnWndProc = WndProc;
  3832. // wndclass.cbClsExtra = 0;
  3833. // wndclass.cbWndExtra = 0;
  3834. // wndclass.hInstance = hInstance;
  3835. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3836. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3837. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3838. // wndclass.lpszMenuName = NULL;
  3839. // wndclass.lpszClassName = szAppName;
  3840. //
  3841. // if (!RegisterClass(&wndclass))
  3842. // {
  3843. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  3844. // return 0;
  3845. // }
  3846. //
  3847. // hwnd = CreateWindow(szAppName, TEXT("Get System Metrics No.2"), WS_OVERLAPPEDWINDOW | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3848. // ShowWindow(hwnd, iCmdShow);
  3849. // UpdateWindow(hwnd);
  3850. //
  3851. // while (GetMessage(&msg, NULL, 0, 0))
  3852. // {
  3853. // TranslateMessage(&msg);
  3854. // DispatchMessage(&msg);
  3855. // }
  3856. // return msg.wParam;
  3857. //}
  3858. //
  3859. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3860. //{
  3861. // static int cxChar, cxCaps, cyChar, cyClient, iVscrollPos;
  3862. // HDC hdc;
  3863. // int i, y;
  3864. // PAINTSTRUCT ps;
  3865. // TCHAR szBuffer[10];
  3866. // TEXTMETRIC tm;
  3867. //
  3868. // switch (message)
  3869. // {
  3870. // case WM_CREATE:
  3871. // hdc = GetDC(hwnd);
  3872. // GetTextMetrics(hdc, &tm);
  3873. // cxChar = tm.tmAveCharWidth;
  3874. // cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
  3875. // cyChar = tm.tmHeight + tm.tmExternalLeading;
  3876. // ReleaseDC(hwnd, hdc);
  3877. // SetScrollRange(hwnd, SB_VERT, 0, NUMLINES - 1, FALSE);
  3878. // SetScrollPos(hwnd, SB_VERT, iVscrollPos, TRUE);
  3879. // return 0;
  3880. //
  3881. // case WM_SIZE:
  3882. // cyClient = HIWORD(lParam);
  3883. // return 0;
  3884. //
  3885. // case WM_VSCROLL:
  3886. // switch (LOWORD(wParam))
  3887. // {
  3888. // case SB_LINEUP:
  3889. // iVscrollPos -= 1;
  3890. // break;
  3891. // case SB_LINEDOWN:
  3892. // iVscrollPos -= 1;
  3893. // break;
  3894. // case SB_PAGEUP:
  3895. // iVscrollPos -= cyClient / cyChar;
  3896. // break;
  3897. // case SB_PAGEDOWN:
  3898. // iVscrollPos = HIWORD(wParam);
  3899. // break;
  3900. // case SB_THUMBPOSITION:
  3901. // iVscrollPos = HIWORD(wParam);
  3902. // break;
  3903. // default:
  3904. // break;
  3905. // }
  3906. //
  3907. // iVscrollPos = max(0, min(iVscrollPos, NUMLINES - 1));
  3908. // if (iVscrollPos != GetScrollPos(hwnd, SB_VERT))
  3909. // {
  3910. // SetScrollPos(hwnd, SB_VERT, iVscrollPos, TRUE);
  3911. // InvalidateRect(hwnd, NULL, TRUE);
  3912. // }
  3913. // return 0;
  3914. //
  3915. // case WM_PAINT:
  3916. // hdc = BeginPaint(hwnd, &ps);
  3917. // for (i = 0; i < NUMLINES; i++)
  3918. // {
  3919. // y = cyChar * (i - iVscrollPos);
  3920. // TextOut(hdc, 0, y, sysmetrics[i].szLabel, lstrlen(sysmetrics[i].szLabel));
  3921. // TextOut(hdc, 22 * cxCaps, y, sysmetrics[i].szDesc, lstrlen(sysmetrics[i].szDesc));
  3922. // SetTextAlign(hdc, TA_RIGHT | TA_TOP);
  3923. // TextOut(hdc, 22 * cxCaps + 40 * cxChar, y, szBuffer, wsprintf(szBuffer, TEXT("%d"), GetSystemMetrics(sysmetrics[i].iIndex)));
  3924. // SetTextAlign(hdc, TA_LEFT | TA_TOP);
  3925. // }
  3926. // EndPaint(hwnd, &ps);
  3927. // return 0;
  3928. //
  3929. // case WM_DESTROY:
  3930. // PostQuitMessage(0);
  3931. // return 0;
  3932. // }
  3933. // return DefWindowProc(hwnd, message, wParam, lParam);
  3934. //
  3935. //}
  3936.  
  3937.  
  3938. //SYSMETS1
  3939.  
  3940. //#include<windows.h>
  3941. //#include "SYSMETS.h"
  3942. //
  3943. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  3944. //
  3945. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  3946. //{
  3947. // static TCHAR szAppName[] = TEXT("SysMets1");
  3948. // HWND hwnd;
  3949. // MSG msg;
  3950. // WNDCLASS wndclass;
  3951. //
  3952. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  3953. // wndclass.lpfnWndProc = WndProc;
  3954. // wndclass.cbClsExtra = 0;
  3955. // wndclass.cbWndExtra = 0;
  3956. // wndclass.hInstance = hInstance;
  3957. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  3958. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  3959. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  3960. // wndclass.lpszMenuName = NULL;
  3961. // wndclass.lpszClassName = szAppName;
  3962. //
  3963. // if (!RegisterClass(&wndclass))
  3964. // {
  3965. // MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);
  3966. // return 0;
  3967. // }
  3968. //
  3969. // hwnd = CreateWindow(szAppName, TEXT("Get System Metrics No.1"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  3970. // ShowWindow(hwnd, iCmdShow);
  3971. // UpdateWindow(hwnd);
  3972. // while (GetMessage(&msg, NULL, 0, 0))
  3973. // {
  3974. // TranslateMessage(&msg);
  3975. // DispatchMessage(&msg);
  3976. // }
  3977. // return msg.wParam;
  3978. //}
  3979. //
  3980. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  3981. //{
  3982. // static int cxChar, cxCaps, cyChar;
  3983. // HDC hdc;
  3984. // int i;
  3985. // PAINTSTRUCT ps;
  3986. // TCHAR szBuffer[10];
  3987. // TEXTMETRIC tm;
  3988. //
  3989. // switch (message)
  3990. // {
  3991. // case WM_CREATE:
  3992. // hdc = GetDC(hwnd);
  3993. // GetTextMetrics(hdc, &tm);
  3994. // cxChar = tm.tmAveCharWidth;
  3995. // cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2)* cxChar / 2;
  3996. // cyChar = tm.tmHeight + tm.tmExternalLeading;
  3997. // ReleaseDC(hwnd, hdc);
  3998. // return 0;
  3999. //
  4000. // case WM_PAINT:
  4001. // hdc = BeginPaint(hwnd, &ps);
  4002. // for (i = 0; i < NUMLINES; i++)
  4003. // {
  4004. // TextOut(hdc, 0, cyChar * i, sysmetrics[i].szLabel, lstrlen(sysmetrics[i].szLabel));
  4005. // TextOut(hdc, 22 * cxChar, cyChar * i, sysmetrics[i].szDesc, lstrlen(sysmetrics[i].szDesc));
  4006. // SetTextAlign(hdc, TA_RIGHT | TA_TOP);
  4007. // TextOut(hdc, 22 * cxCaps + 40 * cxChar, cyChar * i, szBuffer, wsprintf(szBuffer, TEXT("%5d"), GetSystemMetrics(sysmetrics[i].iIndex)));
  4008. // SetTextAlign(hdc, TA_LEFT | TA_TOP);
  4009. // }
  4010. // EndPaint(hwnd, &ps);
  4011. // return 0;
  4012. //
  4013. // case WM_DESTROY:
  4014. // PostQuitMessage(0);
  4015. // return 0;
  4016. // }
  4017. // return DefWindowProc(hwnd, message, wParam, lParam);
  4018. //}
  4019.  
  4020.  
  4021. // HELLOWIN
  4022.  
  4023. //#include <windows.h>
  4024. //
  4025. //LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  4026. //
  4027. //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  4028. // PSTR szCmdLine, int iCmdShow)
  4029. //{
  4030. // static TCHAR szAppName[] = TEXT("HelloWin");
  4031. // HWND hwnd;
  4032. // MSG msg;
  4033. // WNDCLASS wndclass;
  4034. //
  4035. // wndclass.style = CS_HREDRAW | CS_VREDRAW;
  4036. // wndclass.lpfnWndProc = WndProc;
  4037. // wndclass.cbClsExtra = 0;
  4038. // wndclass.cbWndExtra = 0;
  4039. // wndclass.hInstance = hInstance;
  4040. // wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  4041. // wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  4042. // wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  4043. // wndclass.lpszMenuName = NULL;
  4044. // wndclass.lpszClassName = szAppName;
  4045. //
  4046. // if (!RegisterClass(&wndclass))
  4047. // {
  4048. // MessageBox(NULL, TEXT("This program requires Windows NT!"),
  4049. // szAppName, MB_ICONERROR);
  4050. // return 0;
  4051. // }
  4052. //
  4053. // hwnd = CreateWindow(szAppName, // window class name
  4054. // TEXT("The Hello Program"), // window caption
  4055. // WS_OVERLAPPEDWINDOW, // window style
  4056. // CW_USEDEFAULT, // initial x position
  4057. // CW_USEDEFAULT, // initial y position
  4058. // CW_USEDEFAULT, // initial x size
  4059. // CW_USEDEFAULT, // initial y size
  4060. // NULL, // parent window handle
  4061. // NULL, // window menu handle
  4062. // hInstance, // program instance handle
  4063. // NULL); // creation parameters
  4064. //
  4065. // ShowWindow(hwnd, iCmdShow);
  4066. // UpdateWindow(hwnd);
  4067. //
  4068. // while (GetMessage(&msg, NULL, 0, 0))
  4069. // {
  4070. // TranslateMessage(&msg);
  4071. // DispatchMessage(&msg);
  4072. // }
  4073. // return msg.wParam;
  4074. //}
  4075. //
  4076. //LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  4077. //{
  4078. // HDC hdc;
  4079. // PAINTSTRUCT ps;
  4080. // RECT rect;
  4081. //
  4082. // switch (message)
  4083. // {
  4084. //
  4085. // /* case WM_CREATE:
  4086. // PlaySound(TEXT("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC);
  4087. // return 0;*/
  4088. //
  4089. // case WM_PAINT:
  4090. // hdc = BeginPaint(hwnd, &ps);
  4091. //
  4092. // GetClientRect(hwnd, &rect);
  4093. //
  4094. // DrawText(hdc, TEXT("Hello, Windows 98!"), -1, &rect,
  4095. // DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  4096. //
  4097. // EndPaint(hwnd, &ps);
  4098. // return 0;
  4099. //
  4100. // case WM_DESTROY:
  4101. // PostQuitMessage(0);
  4102. // return 0;
  4103. // }
  4104. // return DefWindowProc(hwnd, message, wParam, lParam);
  4105. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement