Board index » delphi » gettext, puttext does not work in Win32 under BCC 5.02

gettext, puttext does not work in Win32 under BCC 5.02

Hi,

Has anybody try to use gettext () and puttext () in Win32 console /
character mode?
I think those two routines will not work if you try to call gettext (1, 1,
80, 25, buffer) and puttext (1, 1, 80, 25, buffer) under BCC 5.02.
Please let me know if there is a solution for the problem.
According to BCC help message that gettext, puttext, window and other
console routines should not be used in Win32s, any reason?

Best regards,
Sandford Jonathan

 

Re:gettext, puttext does not work in Win32 under BCC 5.02


Quote
> I think those two routines will not work

They worked when I tried them.  Did you try them?  If so, what did they not
do?

You DID try them on a real Win32 platform and not as Win32s didn't you?

.  Ed

Re:gettext, puttext does not work in Win32 under BCC 5.02


"Ed Mulroy [TeamB]" <e...@mulroy.org> wrote in message
news:93krrp$hps2@bornews.inprise.com...

Quote
> > I think those two routines will not work

> They worked when I tried them.  Did you try them?  If so, what did they
not
> do?

> You DID try them on a real Win32 platform and not as Win32s didn't you?

> .  Ed

Hi Ed,
I have tried to run the following simple program on Windows 98 console /
character mode window. The problem is when trying to restore the screen by
using puttext. The puttext routine does not restore the screen when the
coordinate is 1, 1, 80, 25. It does restore the screen when the coordinate
is 1, 1, 78, 25.
By the way, why console operation routines such as gotoxy, puttext, gettext
etc should not be used in Win32s?

// Here is the sample routine which was copied from the BCC 5.02 sample
program.

#include <conio.h>

char buffer[4096];

int main(void)
{
   int i;

   clrscr();
   for (i = 0; i <= 20; i++)
      cprintf("Line #%d\r\n", i);
   gettext(1, 1, 80, 25, buffer);

   gotoxy(1, 25);
   cprintf("Press any key to clear screen...");
   getch();
   clrscr();
   gotoxy(1, 25);
   cprintf("Press any key to restore screen...");
   getch();
   puttext(1, 1, 80, 25, buffer);
   gotoxy(1, 25);
   cprintf("Press any key to quit...");
   getch();

   return 0;

Quote
}

Regards,
Sandford Jonathan

Re:gettext, puttext does not work in Win32 under BCC 5.02


I just tried your code with BCB and it had no problems.  I'm on the laptop
right now and it doesn't have BC++.  I'll try it with BC++ later.

Quote
> By the way, why console operation routines such as gotoxy, puttext,
> gettext etc should not be used in Win32s?

Win32s was created to be a Win32 emulation under 16 bit Windows but it is
badly flawed.  Programs often do strange things under it, sometimes doing
things that are not consistent between runs of the program.  If a program
works under Win32s, consider that luck.

.  Ed

Re:gettext, puttext does not work in Win32 under BCC 5.02


Quote
"Sandford Jonathan" <sandf...@rad.net.id> wrote:

>I have tried to run the following simple program on Windows 98 console /
>character mode window. The problem is when trying to restore the screen by
>using puttext. The puttext routine does not restore the screen when the
>coordinate is 1, 1, 80, 25. It does restore the screen when the coordinate
>is 1, 1, 78, 25.

>char buffer[4096];
>   gettext(1, 1, 80, 25, buffer);

        This may or may not have anything to do with your problem,
just throwing out a possibility.  The new 32 bit API is
ReadConsoleOutput(), and uses 4 bytes per cell, not the 2 bytes you
reserved in buffer.  Perhaps increasing buffer will do the trick?
 Otherwise, you might go to the new APIs.

CHAR_INFO buffer[2000]; //char buffer[8000];

void gettext( WORD left, WORD top, WORD right, WORD bottom)
{
// address of rectangle to read from
        SMALL_RECT from={left,top,right,bottom};
// upper-left cell to write to
        COORD to={0,0};
// column-row size of destination buffer
        COORD siz={80,25};
// handle of a console screen buffer (I think it should be global)
        HANDLE stdout=GetStdHandle(STD_OUTPUT_HANDLE);
        ReadConsoleOutput(stdout,&buffer[0],siz,to,&from);

Quote
}

Other Threads