Thread: [Dev-C++] EXE files in Dev-C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Paul H. <dra...@ne...> - 2003-10-29 09:20:38
|
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++.=20
[code]
void bgi_getline(int x, int y, char get_string[70], int num)
{
for(int LOOP2=3D0; LOOP2<70; LOOP2++)
{
get_string[LOOP2]=3D0;
}
void *image;
bool special_key_press=3DFALSE;
char any_string[20];
int size_string_height=3Dtextheight(any_string);
image=3Dnew 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=3D0; LOOP<num; LOOP++)
{
get_string[LOOP]=3Dgetch();
if(get_string[LOOP]=3D=3D0)
{
special_key_press=3DTRUE;
getch();
LOOP--;
}
else if((int)get_string[LOOP]=3D=3D13)
{
get_string[LOOP]=3D0;
return;
}
else if((int)get_string[LOOP]=3D=3D8)
{
if(LOOP=3D=3D0)
{
get_string[LOOP]=3D0;
LOOP--;
}
else
{
get_string[LOOP]=3D0;
putimage(x-3,y-2,image,COPY_PUT);
get_string[LOOP-1]=3D0;
LOOP=3DLOOP-2;
}
}
else if(!(((int)get_string[LOOP]>=3D97) && =
((int)get_string[LOOP]<=3D122)))
{
if(!(((int)get_string[LOOP]>=3D65) && ((int)get_string[LOOP]<=3D90)))
{
if((int)get_string[LOOP]!=3D32)
{
get_string[LOOP]=3D0;
LOOP--;
}
}
}
if(special_key_press=3D=3DFALSE)
{
outtextxy(x, y, get_string);
}
special_key_press=3DFALSE;
}
}
[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!
=
=20
Paul |
|
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
|
|
From: Paul H. <dra...@ne...> - 2003-10-29 14:53:29
|
1. The reason I wrote 'getimage(x-3,y-2,...)' is when I wrote 'getimage(x,
y,...)' it did'nt cover the complete text because the characters sometimes
goes over the actual starting point a little.
2. As for the char[70] parameter, I did that because in my program (which I
was using it for) I used char[70] right through it!
I did'nt need to put anything else in it! But I've changed it now!
3. (How do you check if LOOP (num) characters fits within your allocated
image buffer?) Good point! How do you?
Paul
> 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
|