Gotoxy in Graphics mode? 
Author Message
 Gotoxy in Graphics mode?

Hello!

    I've written some code in graphics mode. I have to text fields that I
need to have input in. Is there a way I can use the Gotoxy in graphics mode?
Is there anything else I can do so the data from the keyboard is entered
where I need it to be?

    Thanks!

    :) Evan Anderson



Wed, 18 Jun 1902 08:00:00 GMT  
 Gotoxy in Graphics mode?



Quote:
> Hello!

>     I've written some code in graphics mode. I have to text fields that I
> need to have input in. Is there a way I can use the Gotoxy in graphics
mode?
> Is there anything else I can do so the data from the keyboard is entered
> where I need it to be?

When you want to write text in graphics mode you should use "OutTextXY"
like this: OutTextXY(0,0,'Hello World');
This equals to: GotoXY(0,0); Write('Hello World');


Wed, 18 Jun 1902 08:00:00 GMT  
 Gotoxy in Graphics mode?
You can use any method which does not write text-mode characters
to screen (aka non-echoing)

This is because writing text-mode char on graphic mode produces garbage.

You may need to read from keyboard char by char.
use (in CRT unit) readkey.

Below is an example on readkey.
Note: this procedure does no echoing, you cannot see what you have typed in
during input.
To print the characters during input, you need to use
OUTTEXTXY(x,y,yourstring);
You need to calculate the text position by using
TEXTWIDTH and TEXTHEIGHT which gives you the exact width/height of text in
graphics mode.
(for all this, please refer to online help document)

Another reminder is BackSpace. If the user press backspace, you need to draw
a small rectangle over the character to 'erase' it, and remove one character
from the input string.

function inputstring:string;
var c:char; s:string;
  finishinput:boolean;
begin
  finishinput:=false;
  s:='';
  repeat
    repeat until keypressed;
    c:=readkey;
    if c>=#32 then s:=s+c else finishinput:=true;
    {  ^^^^^ be careful! does not check special keys at all!}
    {if you need the char of <enter>: #13}
    {for other values (eg arrow) ask here }
  until finishinput;
  inputstring:=s;
end;


Quote:
>Hello!

>    I've written some code in graphics mode. I have to text fields that I
>need to have input in. Is there a way I can use the Gotoxy in graphics
mode?
>Is there anything else I can do so the data from the keyboard is entered
>where I need it to be?

>    Thanks!

>    :) Evan Anderson



Wed, 18 Jun 1902 08:00:00 GMT  
 Gotoxy in Graphics mode?

Quote:

> Hello!
>     I've written some code in graphics mode. I have to text fields that I
> need to have input in. Is there a way I can use the Gotoxy in graphics mode?
> Is there anything else I can do so the data from the keyboard is entered
> where I need it to be?

Well, there's MoveTo (I think, something like that anyway). But what I think
you want is more like OutTextXY. That lets you control where things are
written (note that nothing will be written to the screen unless you tell it
to).

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 Gotoxy in Graphics mode?

Quote:

>You can use any method which does not write text-mode characters
>to screen (aka non-echoing)

>This is because writing text-mode char on graphic mode produces garbage.

What?? DO you use Hercules Graphics card? That to my knowledge is the
only card supported by BGI that produces garbage on text mode. Of course
you need to set directvideo:=false, if you use CRT. Also the CRT output
window is 80x25 (assuming that was the initial mode) while the VGA
graphics is 80x30. So you should do something like:

if getmaxy=479 then windmax:=79+256*29;

Quote:
>You may need to read from keyboard char by char.
>use (in CRT unit) readkey.

Or you could use readln() in normal fashion. The only problem is that
there is no cursor in graphics mode but that is not a major problem as
TP readln does not support any fancy editing.

Here is a test program:

uses dos,crt,graph;

var i:Integer;
    gd,gm:integer;

Begin
  gd:=detect;
  initgraph(gd,gm,getenv('bgi'));
  if graphresult<>grok then exit;
  directvideo:=false;

  if getmaxy=479 then windmax:=79+256*29;
  for i:=1 to hi(windmax)+1 do begin
    gotoxy(i*2,i); Write(i);
  End;
  gotoxy(1,20);
  Writeln('Hit Enter');
  readln;
  closegraph;
End.

The screen is 80x25 on CGA and EGA and 80x30 on VGA.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problem with GotoXY in EGA/VGA text mode (43/50 line mode)

2. Text mode - graphics mode conflict (Help!)

3. Text mode vs graphics mode conflict (Help!)

4. how to change colors in graphic mode?

5. Can I use Graphics Mode in Turbo Vision?

6. Program crashing out of graphics mode under Windows NT 4.0

7. Hi-res graphic mode

8. Graphics mode???

9. Text in graphics mode

10. Fonts in Graphics mode

11. Need routine for printing the screen in graphics mode

12. Hi Color Graphics MOdes

 

 
Powered by phpBB® Forum Software