|
pengpcz wrote: Usually, if we want to connect two clients,we have to create a server...
Only if there is something on that server that one of them needs (e.g., IM server). Otherwise, they can connect directly.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This is the piece of code for which i am getting runtime error
void read_all_pns_files( void )
{
FILE *fp1, *fp2;
char pns_name[12];
short int n, ret;
A320_atp atp_a320;
A330_atp atp_a330;
B320_atp atp_b320;
B330_atp atp_b330;
D320_atp atp_d320;
D330_atp atp_d330;
F340_atp atp_f340;
I320_ATP atp_i320;
I330_ATP atp_i330;
P320_ATP atp_p320;
P330_ATP atp_p330;
struct {
char PARTNUMMER[40];
char AMENDMENT[2];
char MEN_FILE[13];
short int GERAET;
}part;
memset(pns_name,'\0',12);
memset(part.PARTNUMMER,'\0',40);
memset(part.AMENDMENT,'\0',2);
memset(part.MEN_FILE,'\0',13);
if((fp1=fopen("ALL_PNS.DAT", "wb")) != NULL)
{
for(n=0; n<11; n++)
{
sprintf(pns_name, "%s.PNS", check_name[n]);
sprintf(part.MEN_FILE, "%s.MEN", check_name[n]);
if((fp2=fopen(pns_name, "rb")) != NULL)
{
while(!feof(fp2))
{
switch(n)
{
case 0:
ret=fread(&atp_a320, sizeof(atp_a320), 1, fp2);
strcpy(part.PARTNUMMER, atp_a320.PARTNUMMER);
strcpy(part.AMENDMENT, atp_a320.AMENDMENT);
break;
case 1:
ret=fread(&atp_a330, sizeof(A330_atp), 1, fp2);
strcpy(part.PARTNUMMER,atp_a330.PARTNUMMER);
strcpy(part.AMENDMENT, atp_a330.AMENDMENT);
break;
case 2:
ret=fread(&atp_b320, sizeof(B320_atp), 1, fp2);
strcpy(part.PARTNUMMER,atp_b320.PARTNUMMER);
strcpy(part.AMENDMENT, atp_b320.AMENDMENT);
break;
case 3:
ret=fread(&atp_b330, sizeof(B330_atp), 1, fp2);
strcpy(part.PARTNUMMER,atp_b330.PARTNUMMER);
strcpy(part.AMENDMENT, atp_b330.AMENDMENT);
break;
case 4:
ret=fread(&atp_d320, sizeof(D320_atp), 1, fp2);
strcpy(part.PARTNUMMER,atp_d320.PARTNUMMER);
strcpy(part.AMENDMENT, atp_d320.AMENDMENT);
break;
case 5:
ret=fread(&atp_d330, sizeof(D330_atp), 1, fp2);
strcpy(part.PARTNUMMER,atp_d330.PARTNUMMER);
strcpy(part.AMENDMENT, atp_d330.AMENDMENT);
break;
case 6:
ret=fread(&atp_f340, sizeof(F340_atp), 1, fp2);
strcpy(part.PARTNUMMER,atp_f340.PARTNUMMER);
strcpy(part.AMENDMENT, atp_f340.AMENDMENT);
break;
case 7:
ret=fread(&atp_i320, sizeof(I320_ATP), 1, fp2);
strcpy(part.PARTNUMMER,atp_i320.PARTNUMMER);
strcpy(part.AMENDMENT, atp_i320.Amendment);
break;
case 8:
ret=fread(&atp_i330, sizeof(I330_ATP), 1, fp2);
strcpy(part.PARTNUMMER,atp_i330.PARTNUMMER);
strcpy(part.AMENDMENT, atp_i330.Amendment);
break;
case 9:
ret=fread(&atp_p320, sizeof(P320_ATP), 1, fp2);
strcpy(part.PARTNUMMER,atp_p320.PARTNUMMER);
strcpy(part.AMENDMENT, atp_p320.AMENDMENT);
break;
case 10:
ret=fread(&atp_p330, sizeof(P330_ATP), 1, fp2);
strcpy(part.PARTNUMMER,atp_p330.PARTNUMMER);
strcpy(part.AMENDMENT, atp_p330.AMENDMENT);
break;
default:
break;
}
part.GERAET = n;
if(ret==1) fwrite(&part, sizeof(part), 1, fp1);
}
}
if(fp2)
fclose(fp2);
}
if(fp1)
fclose(fp1);
}
}
I am getting run-time CHECK FAILURE #2 stack around the variable 'part' was corrupted.
Thanks for your help
|
|
|
|
|
Where does check_name[] come from? How is initialized?
BTW enclose code in <pre> tags, for instance
<pre>
</pre>
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
static char check_name[12][5] = {
"A320", "A330", "B320", "B330", "D320",
"D330", "F340", "I320", "I330", "P320", "P330" };
this is how check_name is initialized.
|
|
|
|
|
OK, it looks fine. Now, could you please reformat OP code using <pre> tags?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
modified on Friday, January 18, 2008 5:10:20 AM
|
|
|
|
|
what do you mena by OP code
|
|
|
|
|
The (long) code snippet of the original post.
You may also repost it, correctly formatted, of course.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Have you used the debugger to single-step through the code to find the offending statement(s)?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Comment #1: Try to remove "magic numbers" in the code.
Comment #2: check_name is intialized with how many values?
What happens in the following code if, by some chance, check_name[n] is a character string longer than 11?
char check_name[12][5];
char pns_name[12];
sprintf(pns_name, "%s.PNS", check_name[n]);
Comment #3: Walk through code in the debugger. Use small numbers.
|
|
|
|
|
I am drawing a bitmap on dc using loadImage() and bitblt method
it is working fine. but my problem is that I cannot change the alpha
values of the image i.e. from 0 - 255
Trioum
|
|
|
|
|
AlphaBlend () API can be used.
Come online at:-
jubinc@skype
|
|
|
|
|
but it works with 32bit bitmap I am working with 24 bit.
Trioum
|
|
|
|
|
AFAIK 24 bit bitmaps have not an alpha channel, Am I wrong?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Sorry for quering .I am reviewing my question again actually
I want to set the transparency of the bitmap i.e. from (0-255).
Trioum
|
|
|
|
|
How are you displaying your bitmap ? And what do you need to do exactly ? Do you only need to have some parts of your bitmap transparent ? If yes, take a look at TransparentBlt[^]
|
|
|
|
|
No transparent blt transparent some part. I want the whole image
Trioum
|
|
|
|
|
Why you can't use 32-bit ones?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Did you try with CImage::AlphaBlend ?
|
|
|
|
|
Do you want to actually alter the bitmap pixel data or
just draw the bitmap with adjustable transparency?
To draw with transparency, you can use AlphaBlend(). The
bitmap does NOT have to be 32-bit, but you need to initialize
the BLENDFUNCTION properly:
BLENDFUNCTION blendfunc;
blendfunc.BlendOp = AC_SRC_OVER;
blendfunc.BlendFlags = 0;
blendfunc.SourceConstantAlpha = 40;
blendfunc.AlphaFormat = 0;
To change the pixel data, load it as a DIBSection and loop through the pixel data
applying alpha to each pixel's data.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yes I want that stuff you are right . but when I am using it
BLENDFUNCTION *blendfunc;
blendfunc.BlendOp = AC_SRC_OVER;
blendfunc.BlendFlags = 0;
blendfunc.SourceConstantAlpha = 40; // Set your transparency (0-255) here!blendfunc.AlphaFormat = 0; //Don't use AC_SRC_ALPHA for 24-bit images - there is NO source alpha data
AlphaBlend(m_DC,0,0,720,576,memDC,0,0,100,100,blendfunc);
where 100 100 is height and width of image
error fires call of non function
Trioum
|
|
|
|
|
blendfunc should NOT be a pointer.
BLENDFUNCTION blendfunc;
blendfunc.BlendOp = AC_SRC_OVER;
blendfunc.BlendFlags = 0;
blendfunc.SourceConstantAlpha = 40;
AlphaFormat = 0;
AlphaBlend(m_DC,0,0,720,576,memDC,0,0,100,100,blendfunc);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
On the AlphaBlend() line?
If so, you may need to define WINVER to something >= 0x0400.
This needs to be before any windows or MFC #included header
files.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can use of CImage class and use of SetPixelRGB.
|
|
|
|
|
Solve It .Actually I am using plan SDK .I cannot use CImage.
thanks Marks
Trioum
|
|
|
|
|