Advertisement
Guest User

Untitled

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