Advertisement
Guest User

Untitled

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