Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. {$H+}
  2. Program KeyTestWin.pas;
  3. Uses PTCGraph, CRT, PTCCRT, Windows,sysutils;
  4. Const
  5. ConsoleTitle='Hello World';
  6. GraphTitle='Hello Graphics';
  7. Var
  8. Test,TestWin:Char;
  9. GD,GM,linenum:Integer;
  10. ConsoleWindow,GraphWindow: handle;
  11. outtext:ansistring;
  12. Procedure Outputcodes;
  13. Begin
  14. Writeln (outtext);
  15. if linenum>=40 then
  16. Begin
  17. clearviewport;
  18. Linenum:=0;
  19. End;
  20. Outtextxy(20,20+(Linenum*10),outtext);
  21. inc(linenum);
  22. End;
  23. Begin
  24. gd:=D8bit;
  25. gm:=m640x480;
  26. Windowtitle:=Graphtitle;
  27. Initgraph(gd,gm,'');
  28. SetConsoleTitle(ConsoleTitle);
  29. Sleep(60);
  30. ConsoleWindow:=FindWindow(nil,ConsoleTitle);
  31. GraphWindow:=FindWindow(nil,Pchar(graphtitle+#0#0));
  32. Writeln('Console Window Handle: ',ConsoleWindow);
  33. Writeln(' Graph Window Handle: ',GraphWindow);
  34. ShowWindow(ConsoleWindow, SW_SHOWNORMAL);
  35. SetForegroundWindow(ConsoleWindow);
  36. Linenum:=0;
  37. repeat
  38. if ptccrt.keypressed then
  39. Begin
  40. TestWin:=PTCcrt.Readkey;
  41. if Testwin<>Chr(0) then
  42. Begin
  43. outtext:=testwin+' Graph KeyCode: '+inttostr(Ord(Testwin));
  44. Textcolor(10);
  45. Setcolor(10);
  46. outputcodes;
  47. end
  48. Else
  49. begin
  50. testwin:=ptccrt.readkey;
  51. outtext:=testwin+' Graph Extended: '+inttostr(Ord(Testwin));
  52. Textcolor(11);
  53. setcolor(11);
  54. outputcodes;
  55. end;
  56. if Testwin='C' Then
  57. ShowWindow(ConsoleWindow,SW_hide);
  58. if Testwin='c' Then
  59. Begin
  60. ShowWindow(ConsoleWindow,SW_show);
  61. SetActiveWindow(ConsoleWindow);
  62. SetForegroundWindow(ConsoleWindow);
  63. End;
  64. End;
  65. If crt.Keypressed Then
  66. Begin
  67. test:=CRT.Readkey;
  68. if Test<>Chr(0) then
  69. Begin
  70. outtext:=test+' CRT KeyCode: '+inttostr(Ord(Test));
  71. Textcolor(13);
  72. setcolor(13);
  73. outputcodes;
  74. end
  75. Else
  76. begin
  77. Test := crt.readkey;
  78. outtext:=test+' CRT Extended: '+inttostr(Ord(Test));
  79. Textcolor(14);
  80. setcolor(14);
  81. outputcodes;
  82. end;
  83. if Test='G' Then
  84. ShowWindow(graphwindow,SW_hide);
  85. if Test='g' Then
  86. Begin
  87. ShowWindow(graphwindow,SW_show);
  88. SetActiveWindow(graphwindow);
  89. SetForegroundWindow(graphwindow);
  90. End;
  91. end;
  92. sleep(100);
  93. Until (Test=Chr(27)) or (TestWin=Chr(27)) ;
  94. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement