|
About optimisation...
I usend the CMemFile in C++ to read full file into the memory, and then worked with the memory like with file...
I would like to use this way here... So, how to read the file into the memory and then create BinaryReader to this block of memory... I think there must be some method to convert from byte array to ByteStream....
Please Help...
|
|
|
|
|
You're looking for the
System.IO.MemoryStream class.
Regards
Senthil
_____________________________
<font face="Verdana" size="1"><a href="http://blogs.wdevs.com/senthilkumar">My Blog</a> | <a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=492196">My Articles</a> | <a href="http://geocities.com/win_macro">WinMacro</a></font>
|
|
|
|
|
I wiold like to do paging say by 1 , 2, 3 or next/Previous in datagrid (In Win form application)
Any Input or Sample code please?
|
|
|
|
|
It would ask a lot of work, but you can do the following:
Create two datasets, one dataset has all the data, the second one only has the records to view (one page at a time).
page = 30 records (begins at 0)
beginrecord = page * 30
endrecord = (page * 30) + 30
Every time you go to the next or previous page execute the following procedure for the new page (clear the view dataset first):
string configuredTable = "MyTable";
DataSet myDataSet = new DataSet();
for(int index = beginrecord; index < endrecord; index++)
{
DataRow newrow = viewdataset.Tables[configuredTable].NewRow();
viewdataset.Tables[configuredTable].AddRow(newrow);
}
viewdataset.AcceptChanges();
walk through the dataset table with the records you want to display and add them to a separate dataset. (Don't forget to call AcceptChanges() )
There's one problem though: You should not edit the records in the view dataset, because that one gets cleared every time you change the page. Ofcourse you can implement the DataRowAdded eventhandler and add the same data to the non-view dataset.
WM.
What about weapons of mass-construction?
|
|
|
|
|
HellO!
Who knows ESRI Shape file format, will understand my problem...
I got a shape file, where some integers are in little endian format and other are in big endian format... So, my question is - how to convert this two formatsa between each other? For example i have an integer a in BigEndian format, i'd like to see it in Little Indian format... Thaks...
|
|
|
|
|
Converting from big endian to littel endian is just a matter of reversing the bytes, isn't it? You can do that easily with code like this.
int ReverseBytes(int original)
{
int reversed = 0;
for (int i = 0; i<4; i++)
{
reversed |= (byte)(original & 0x000000FF);
reversed << 8;
original >> 8;
}
return reversed;
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Small correction...if you loop 4 times you drop bytes off the right hand side of the reversed integer, so it should be like this (note also use of unsigned):
<br />
<br />
unsigned int reversed = 0;<br />
<br />
for (int i = 0; i<3; i++)
{<br />
reversed |= (BYTE)(original & 0x000000FF);<br />
reversed = reversed << 8;<br />
original = original >> 8;<br />
}<br />
<br />
<br />
reversed |= (BYTE)(original & 0x000000FF);<br />
|
|
|
|
|
Yeah, you were right, there was an off by one error. Here's the right code.
int reversed = 0;
for (int i = 0; i<4; i++)
{
reversed <<= 8;
reversed |= (byte)(original & 0x000000FF);
Console.WriteLine("{0:x}", reversed);
original >>= 8;
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Apologies, my previous post had a small bug which caused an extra left shift to occur. Here's the correct code
int reversed = 0;
for (int i = 0; i<4; i++)
{
reversed <<= 8;
reversed |= (byte)(original & 0x000000FF);
original >>= 8;
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
what is the best way to have a client wait for a response from the server? like a login system where the client sends the login info to the server and while the server checks the login info in a database the clients main thread holds till the read thread get a response from the server like good login or bad login.
|
|
|
|
|
Anonymous wrote:
what is the best way to have a client wait for a response from the server?
Busy mouse pointer?
<italic>Work hard, Work effectively.
|
|
|
|
|
I'm trying to develop an add-in for Outlook Express, the add-in is supposed to intercept sending mails and (optionally) add attachments to the mail being sent.
I have already done that on Microsoft Outlook using Visual Studio Tools for Office, but I couldn't find any way to do it on Outlook Express.
Help would be greatly appreciated, just point me on the way.
Thanks in advance,
Wessam Fathi
Wessam Fathi
|
|
|
|
|
As far is i know there is no extension API for Outlook Express.
The only way i could think of doing this is to have a Proxy SMTP-Server handling all outgoing mails.
/cadi
24 hours is not enough
|
|
|
|
|
Is there a simple way how to determine, if there's enough memory for a new object, if I know its size?
For example, I have an imaging app and user (ape) wants to resize image to 34676x80900 pixels. It's too much for his machine, but app will try to create a huge bitmap this way:
<br />
try {<br />
<br />
bmp = new Bitmap(userSize.Width, userSize.Height);<br />
} catch () {<br />
<br />
}<br />
My real application works with many Image objects and only dummy proofing are try-catch blocks, which are not preventing exceptions and are very slow.
|
|
|
|
|
No, there isn't. You can only rough-guess if you've got enough free memory. Because if you have the amount you need, there's no way to tell that if, in that moment, it's all continguous.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey.. I'm very new to this but I'll try explaining the best I can.
Say I have a function in a "class library" project which gets imported by my "ASP.NET Web Application".
Now in my ASP.NET project I got:
private void Button1_Click(object sender, System.EventArgs e)
{
TestClass test = new TestClass();
test.TestFunction();
}
and my TestFunction looks like this:
public void TestFunction()
{
Console.WriteLine( "testing.." );
}
How would I go about writing the output of my TestFunction() to the actual page in my ASP.NET project? Do I need to set the message from TestFunction() to a public string and then use that string to display what I need on the web page?
Another example..
public void TestFunction()
{
try
{
Console.WriteLine( "testing.." );
}
catch( Exception E )
{
Console.WriteLine( "Ex: {0}", E.Message );
}
}
if TestFunction() should error now, it'll print out the Exception message to the console.. but I need it to print to the web page instead. I guess setting a string to the text now is not going to work.
Hope you understand and thanks for the help!
|
|
|
|
|
Make your function return the output as a string:
public string TestFunction() {<br />
return "Testing...";<br />
}
From the page, you can put the text in a control:
private void Button1_Click(object sender, System.EventArgs e) {
TestClass test = new TestClass();
MyControl.Text = test.TestFunction();
}
For the error handling, you can store the error text in a local variable, and supply a property for fetching the value. You can return a null value from the function to signal that an error occured:
private string lastError;
public string LastError { get { return lastError; } }
public string TextFunction() {
try {
return "Testing...";
} catch (Exception E) {
lastError = E.Message;
return null;
}
}
---
b { font-weight: normal; }
|
|
|
|
|
I see. Thanks alot for your reply!
|
|
|
|
|
hi all.
I have some problems in programming rich text box i succeeded to draw an image inside text box as emoticons by using dataformats and clipboard but the problems are:
1- the emoticons entered inside the rtb unanimated even if it is animated how can i implement that emoticons animated ?????????????
2- when the emoticons entered the richtext box if you point with your mouse pointer on it in rtb you can resize it how can i make it fixed ?????????
3- when i press my send button to send emoticons to the other user in chat the previous emoticons in my rich text box disappears and even the previous one transfered disappears in the private chat of the other user.
how can i make the emoticons don't disappears and make my rtb contains all the emoticons ?
Any help with this please .
i used the following code.
<br />
<br />
Bitmap myemot = new Bitmap(dialog.filename);<br />
ClipBoard.setDataObject(myemot);<br />
DataFormats.Format chm = DataFormats.GetFormat(DataFormats.Bitmap);<br />
rtb.text +=myusername + " \r\n";<br />
if(rtb.canpaste(chm))<br />
{<br />
rtb.paste(chm);<br />
}<br />
The Above Code makes the bitmap enter the rtb but with the previous problems any help with that please
Mess With The Best And Die Like The Rest
Miss With The Best And Die Like The Rest
|
|
|
|
|
is there a way to give basic windows controls a better look, like a skin ect.. or do you have to create a custom control?
if I have to make a custom control anyone know of a good sample?
thanks
j
|
|
|
|
|
There are heaps of samples on this very site. I think XP has some options for controls, but overall, if you want to change how they look, you need to draw them yourself.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello all,
After reading almost all tutorials on splash screen for C# I'm quite confused which aproach to take. So I want to ask you what would be the best way. Personally, what I've been thinking is doing something like this:
1. In Main() start the splash thread
2. Run the Main form thread
3. main form thread sends signals to the splash thread about the progress
4. main form sends a signal to the splash thread that it has finished and the splash thread closes itself
The thing is that I've done some threading recently but I haven't actually encountered how to call object methods on different threads. Another thing which I'm not sure about is, should the function which is to be called for the start point of the thread call Application.Run(SplashThread) for the splash thread and Application.Run(MainForm) ? Any advice is greatly appreciated.
|
|
|
|
|
I don't see the need for another thread. Your main thread can just open a window which shows the splash screen, then close it using either a timer, or at a specific point during initialisation ( i.e. just before the main app is ready to show itself ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
But if I show the splash using Application.Run(Splash); the function will return when the splash is closed, am I right? If it's that way, then I'm in a deadlock. That's why I resort the threads.
|
|
|
|
|
1nsp1r3d wrote:
Application.Run(Splash);
Why would you do this ? I'm talking about a modeless form being shown by your application, during startup. Sure, you can use a thread, it just seems like overkill to me.
Christian Graus - Microsoft MVP - C++
|
|
|
|