Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$H+}
- Program KeyTestWin.pas;
- Uses PTCGraph, CRT, PTCCRT, Windows,sysutils;
- Const
- ConsoleTitle='Hello World';
- GraphTitle='Hello Graphics';
- Var
- Test,TestWin:Char;
- GD,GM,linenum:Integer;
- ConsoleWindow,GraphWindow: handle;
- outtext:ansistring;
- Procedure Outputcodes;
- Begin
- Writeln (outtext);
- if linenum>=40 then
- Begin
- clearviewport;
- Linenum:=0;
- End;
- Outtextxy(20,20+(Linenum*10),outtext);
- inc(linenum);
- End;
- Begin
- gd:=D8bit;
- gm:=m640x480;
- Windowtitle:=Graphtitle;
- Initgraph(gd,gm,'');
- SetConsoleTitle(ConsoleTitle);
- Sleep(60);
- ConsoleWindow:=FindWindow(nil,ConsoleTitle);
- GraphWindow:=FindWindow(nil,Pchar(graphtitle+#0#0));
- Writeln('Console Window Handle: ',ConsoleWindow);
- Writeln(' Graph Window Handle: ',GraphWindow);
- ShowWindow(ConsoleWindow, SW_SHOWNORMAL);
- SetForegroundWindow(ConsoleWindow);
- Linenum:=0;
- repeat
- if ptccrt.keypressed then
- Begin
- TestWin:=PTCcrt.Readkey;
- if Testwin<>Chr(0) then
- Begin
- outtext:=testwin+' Graph KeyCode: '+inttostr(Ord(Testwin));
- Textcolor(10);
- Setcolor(10);
- outputcodes;
- end
- Else
- begin
- testwin:=ptccrt.readkey;
- outtext:=testwin+' Graph Extended: '+inttostr(Ord(Testwin));
- Textcolor(11);
- setcolor(11);
- outputcodes;
- end;
- if Testwin='C' Then
- ShowWindow(ConsoleWindow,SW_hide);
- if Testwin='c' Then
- Begin
- ShowWindow(ConsoleWindow,SW_show);
- SetActiveWindow(ConsoleWindow);
- SetForegroundWindow(ConsoleWindow);
- End;
- End;
- If crt.Keypressed Then
- Begin
- test:=CRT.Readkey;
- if Test<>Chr(0) then
- Begin
- outtext:=test+' CRT KeyCode: '+inttostr(Ord(Test));
- Textcolor(13);
- setcolor(13);
- outputcodes;
- end
- Else
- begin
- Test := crt.readkey;
- outtext:=test+' CRT Extended: '+inttostr(Ord(Test));
- Textcolor(14);
- setcolor(14);
- outputcodes;
- end;
- if Test='G' Then
- ShowWindow(graphwindow,SW_hide);
- if Test='g' Then
- Begin
- ShowWindow(graphwindow,SW_show);
- SetActiveWindow(graphwindow);
- SetForegroundWindow(graphwindow);
- End;
- end;
- sleep(100);
- Until (Test=Chr(27)) or (TestWin=Chr(27)) ;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement