|
From: Per W. <pw...@ia...> - 2003-10-29 13:44:25
|
No, I haven't seen the reason for your problem. However, just some
questions:
- You assume that x >= 3, since you do getimage(x-1,...)
- You assume that y >= 2, ...
- As input you take a char[70] parameter but inside, you use num+1
positions - why not just say char get_string[].
- How do you check if LOOP (num) characters fits within your allocated
image buffer?
/Per W
On Wed, 29 Oct 2003, Paul Hester wrote:
> I've created a program in Dev-C++ and have no problem runing it! But when i try to run it from the .EXE file it seems to behave differently. The problem is I've created a function similar to 'cin.getline()' but for 'BGI' graphics, the function works fine when i run it in Dev-C++.
>
> [code]
>
> void bgi_getline(int x, int y, char get_string[70], int num)
> {
> for(int LOOP2=0; LOOP2<70; LOOP2++)
> {
> get_string[LOOP2]=0;
> }
> void *image;
> bool special_key_press=FALSE;
> char any_string[20];
> int size_string_height=textheight(any_string);
> image=new char[imagesize(x-3,y-2,getmaxx(),y+size_string_height+5)];
> getimage(x-3,y-2,getmaxx(),y+size_string_height+5,image);
> for(int LOOP=0; LOOP<num; LOOP++)
> {
> get_string[LOOP]=getch();
> if(get_string[LOOP]==0)
> {
> special_key_press=TRUE;
> getch();
> LOOP--;
> }
> else if((int)get_string[LOOP]==13)
> {
> get_string[LOOP]=0;
> return;
> }
> else if((int)get_string[LOOP]==8)
> {
> if(LOOP==0)
> {
> get_string[LOOP]=0;
> LOOP--;
> }
> else
> {
> get_string[LOOP]=0;
> putimage(x-3,y-2,image,COPY_PUT);
> get_string[LOOP-1]=0;
> LOOP=LOOP-2;
> }
> }
> else if(!(((int)get_string[LOOP]>=97) && ((int)get_string[LOOP]<=122)))
> {
> if(!(((int)get_string[LOOP]>=65) && ((int)get_string[LOOP]<=90)))
> {
> if((int)get_string[LOOP]!=32)
> {
> get_string[LOOP]=0;
> LOOP--;
> }
> }
> }
> if(special_key_press==FALSE)
> {
> outtextxy(x, y, get_string);
> }
> special_key_press=FALSE;
> }
> }
>
> [end code]
>
> When i run this in Dev-C++ it works fine but when i run the program from the .EXE file it has a problem with the delete feature in 'void bgi_getline(int, int, char, int)' As you can see in the code it gets the image of the background first with 'getimage()' then puts it back with 'putimage()' so you can see the new string. In the .EXE file it deletes but you can still see the old string there! For some weird reason it is not using the 'getimage()' and 'putimage()' functions properly!
> If anyone can help me in any way that would be great! Thank You!
>
> Paul
|