|
|
I know what x0D is.
The question is: does FileStream actually corrupt in incoming data file by adding this extra character to the stream?
Allen Gleazer
|
|
|
|
|
Depends How you use it. If you use command from BinaryReader ReadBytes, Then incoming data will not be corupted.
Below is C++ Sample for copying File, I have tried about 1MB of File, and it make 1:1 Copy. (No Difrence)
String *fileName1 = S"Old.Dat";<br />
String *fileName2 = S"New.Dat";<br />
FileStream *fsOld = new FileStream(fileName1, FileMode::Open);<br />
FileStream *fsNew = new FileStream(fileName2, FileMode::Create);<br />
<br />
BinaryReader *br = new BinaryReader(fsOld);<br />
BinaryWriter *bw = new BinaryWriter(fsNew);<br />
do <br />
{<br />
if (br->BaseStream->Length == br->BaseStream->Position)<br />
break;<br />
<br />
Byte q[] = br->ReadBytes(10);<br />
bw->Write(q);<br />
<br />
} while(true);<br />
br->Close();<br />
bw->Close();
|
|
|
|
|
That's what I thought, too, but when I used the ReadBytes method of the Binary Reader, it made no difference. Then, in debug mode I took a look at the input buffer of the FileStream object (before the data even gets to the reader) and saw that the extra x0D character had already been inserted in the FileStream buffer.
Did the the input data in your test contain an isolated x0A somewhere in the input data?
Allen Gleazer
|
|
|
|
|
I Have tried and it didn't inserted in the file.
How do you declare?
Can you put code sample?
|
|
|
|
|
This is realy realy late post. (A Year)
At that time, i didn't know what can be wrong, but i have recently have some simular problem. I found this post when i was cleaning my e-mail box.
StreamReader ^sr = gcnew StreamReader(File::OpenRead("test.txt"), Encoding::Default);
Encoding::Default is using windows default setting. If you don't specificy the encoding it will use UTF7 encoding by default.
|
|
|
|
|
Hi,
I am speccing an application that requires a listbox control whose rows contain other (output-only) controls; namely a static image, a drawn image (i.e. can't be in a file), a progress bar and some plain text. Something like:
#pic# < Image > [---Bar-- ] Text<br />
All in one row, with different controls simultaneously visible in other rows.
I know it is possible to OwnerDraw all this from scratch.
Is it possible to build it up using existing other controls, esp. the progressbar control.
Any thoughts?
Ruth
|
|
|
|
|
|
Thanks for the link: it was useful.
Do you suggest the DataGrid because you know the ListBox cannott do what I want?
|
|
|
|
|
I am glad that you found the link useful. I certainly found it to be an interesting article. I have seen the ListBox control customised but not to the extent that you require. The DataGrid control was built with extensibility in mind whereas the ListBox control was always meant to be a simple control for simple situations.
Perhaps it is possible to do what you are asking with the ListBox control but I am not sure how you would go about it. I would personally stick with a method that is well documented and that is easier to find help for if you run into problems.
|
|
|
|
|
Hi,
I have the following problem and I would appreciate any help on it.
I want to create an OCX in unmanaged side and I would like to use/access a .NET component from it. Say the component want to access is a .NET control like a grid. Don't I need to specify to transfer the information about the parent window of the gridcontrol, which is my ActiveX window? How can I do this? How can I pass a window handle to the gridcontrol?
Please help.
Thanks a lot.
|
|
|
|
|
I have Visual Studio 2002 installed and would like to install VS 2003 on the same machine. I don’t want any old project-files from VS 2002 to be changed.
Is this possible or must VS 2002 bee uninstalled before?
_____________________________
...and justice for all
APe
|
|
|
|
|
sure you can...
it is the same (i think) as installing VStudio 2003 when you already had a Visual Studio 6...
when you try to open a project created with VS2002, just tell windows to "open with" ... visual Studio .NET 2002
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Ok. I'll do It in 2 days... Tnx
_____________________________
...and justice for all
APe
|
|
|
|
|
Hello, I am currently trying to develop a video game using .NET C++. The one thing I am having trouble with is when I move (with a Key_Down event) a pictureBox with an image set, there is always a lag, and thus a piece of the image's last position always appears. How would I get rid of this?? I had tried making it invisible, changing the pictureBox's location, then making it visible again, but that makes the image blink as it moves. Any help would be greatly appreciated. Thank you.
Michael
|
|
|
|
|
Hi,
in a video game you shouldn't use a picture box. Remove it and paint the bitmap yourself onto the form/control/whatever by overriding the Paint method (don't forget to call the base implementation) and calling e.Graphics.DrawImage. This should be by far faster than the picturebox.
|
|
|
|
|
Hey thanks, I tried that and it worked a lot better, however the image still jumps and is blurry as I move it. Would there be a way to get rid of that? I know that in java they use a buffering strategy, however I do not know how to do that in .NET C++. Thanks for the help so far.
Michael
|
|
|
|
|
(I'll use C# syntax as Im not very familiar with C++)
A simple double buffering can be enabled by adding this in the constructor of your form/control:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
Does your image have the correct size or do you resize it while painting? If it has already the correct size use the DrawImageUnscaled function. If not resize it somewhere in the beginning:
Bitmap resizedBitmap = new Bitmap(wantedWidth, wantedHeight);
Graphics g = Graphics.FromImage(resizedBitmap);
g.DrawImageUnscaled(oldBitmap, 0, 0, wantedWidth, wantedHeight);
g.Dispose();
EDIT: You should also search for 'double buffering' here on CodeProject. There are some articles which might be interesting for you.
|
|
|
|
|
the C# syntax isn't that different (I just used :: instead of .) however the buffer didn't appear to do anything. I guess it isn't possible to get rid of the flicker when painting an image, however I still do not know how it is done in java, but can't be done in .NET C++. Also, did you mean to make a paint event for the form, and then e->Graphics->DrawImage it, because that is what I did. Anyways, thanks again for the help.
Michael
|
|
|
|
|
No I meant overriding the OnPaint method of the form (but that shouldn't make a difference). I made a simple text which work fine for me (when the image is very big it slows down). Probably it helps you:
public class Form1 : System.Windows.Forms.Form
{
private Point _curPos = new Point(0, 0);
private Image _image;
public Form1()
{
base.KeyPress += new KeyPressEventHandler(Form1_KeyPress);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
_image = new Bitmap("C:\\test2.jpg");
}
private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case 'w': _curPos.Y -= 5; break;
case 's': _curPos.Y += 5; break;
case 'a': _curPos.X -= 5; break;
case 'd': _curPos.X += 5; break;
}
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
e.Graphics.DrawImageUnscaled(_image, _curPos);
}
}
Note that I'm calling the Invalidate method instead of Refresh. This is always better because the Refresh will repaint the form immediatly while Invalidate will wait until there is time to do so. If you have much more other things on your form it would also be a good idea to give a Rectangle into the form which specifies which particular region should be repainted.
|
|
|
|
|
Hi.
I am new to the .NET Framework and to the Enterprise Library. I was wondering if the Enterprise Library facilitates developers in implementing different acces levels, e.g.: an administrator will be able to view usernames&passwords, while a customer in the development department will not have such access.
Thank you,
Elena
|
|
|
|
|
I wrote a DirectX 9 program with C#.NET and it would not run on my non-development machine. I keep getting this type of error:
Application has generated an exception that could not be handled.
Process id=0xedc (3804), Thread id=0xee0 (3808)
Click OK to terminate the application.
Click CANCEL to debug the application.
I get this error from running the DirectX Tutorial program from this site as well. The programs run fine on my development machine.
Does anyone know what's cauing this problem? It's not limited to this machine. Other non-development machines also have errors running the programs. I think this problem is caused by DirectX because other .NET applications run fine.
Thanks.
|
|
|
|
|
The information you gave here just states that your application has crashed.
Where and why cannot be determined from this info.
Use try/catch to find out where your app crashes.
Regards,
mav
|
|
|
|
|
Thanks for the reply. I found the problem. The machine did not have Managed DirectX installed. I installed the June redist and it worked fine.
On a side note, I've tried adding try/catch blocks to every method in my program and that didnt do anything.
|
|
|
|
|
I've faced a strange problem in the ListView control when I mirror it to support the right-to-left layout. I am talking about .NET 1.1. When a ListView control is mirrored, ListViewItems do the mirroring, but ClomnHeader controls do not, i.e. it keeps to display as left-to-right.
Here is an example of what I've described,
http://www.elc4sa.com/mr.gif
Any ideas ??
|
|
|
|