|
lol!
bugger - all that work
oh well, at least i know I can marshal IStream....
Cheers mate
Cata
|
|
|
|
|
*sticks tongue out at Heath* There! *I* answered one for once!
[EDIT:] BTW Heath, wasn't around to congratulate you on your "MVP-ness"[/EDIT]
|
|
|
|
|
Oh yeah...well...well...I have over 3,400 posts! Hah!
Thanks, BTW!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This really sucks.
It doesn't give you a valid result for how many elements were retrieved, always a zero IntPtr, so you don't know when you reach the end of the stream, and you can't collect the error value because it returns void.
wtf are Microsoft playing at?
I have to copy the buffer on each iteration, and compare the array of bytes now to see if they are identical. THEN i have to figure out where the stream ends in the frickin buffer. That's LAME man. I did a better job than that. *GRRRR*
Cata
|
|
|
|
|
|
I've decided i'm going to stick with my own implementation, as having no value is of little use. The resultant intptr from read is always zero (null). I spent a while with it, but MS descided that no return value was nescessary... lovely.
I've got it so that it reads the byte array, and converts it into a string. Nifty. I am a very happy little computer geek
Here is what I have:
pIStream.Seek(pInZero,STREAM_SEEK_Flags.STREAM_SEEK_SET, out pSeekResult);<br />
<br />
sbyte[] buffer = new sbyte[bufferSize];<br />
<br />
string charReader = "";
int read;
<br />
do<br />
{<br />
pIStream.Read(buffer, bufferSize, out read);<br />
<br />
if (read != 0)<br />
{<br />
unsafe<br />
{<br />
fixed(sbyte* pChars = buffer)<br />
{<br />
charReader += new string(pChars,0,read,System.Text.Encoding.ASCII);<br />
}<br />
}<br />
}<br />
}while (read != 0);
it works fine, reading huge text documents.
I'm interested as to what else I can do with it.
I think i need to start building a decent layout, my test program has got pretty big, and ugly as sin. That said... IT WORKS! ^^
Cata
|
|
|
|
|
If you don't want to convert the VB.NET code yerself, here's a quick try at it:
UCOMIStream stream = ...;
int offset = ....;
int count = ....;
byte[] resultBuffer;
if( stream == null ) throw new ObjectDisposedException("stream");
int bytesRead = 0;
object boxBytesRead = bytesRead;
GCHandle hObject;
try {
hObject = GCHandle.Alloc(boxBytesRead, GCHandleType.Pinned);
IntPtr pBytesRead = hObject.AddressOfPinnedObject();
if( offset != 0 ) {
byte[] tmpBuffer = new byte[count - 1];
stream.Read( tmpBuffer, count, pBytesRead );
bytesRead = (int)boxBytesRead;
System.Array.Copy( tmpBuffer, 0, resultBuffer, offset, bytesRead);
} else {
stream.Read( resultBuffer, count, pBytesRead );
bytesRead = (int)boxBytesRead;
}
} finally {
if( hObject.IsAllocated() ) {
hObject.Free();
}
}
}
Not tested, of course....
Jeremy Kimball
|
|
|
|
|
I take it by doing it the way i posted above, i'm getting an int from a pointer, and not handling it properly.
That will lead to memory leaks? Unless i unallocate it?
Cata
|
|
|
|
|
I hope I can explain this well enough to make sense, I am writing a C#/ASP app where I have a grid (4x3) of buttons on a page. Each one is named btnMonth1, btnMonth2 - btnMonth12 I am working with some database stuff where they may only be working on certain months at a time so depending on what number is in the data I would like to make it visible... so if I had a variable mth I would want to somehow say btnMonth(mth).visible = true; AFAIK in C++ you can do this by incrementing it but I don't think forms use resource ID's so I am not sure this would work.
I'm trying to learn something at the same time while trying to cut a big switch statement out of the mix that seems unnecessary. Maybe that's how it should be done though?
Any help is appreciated
Thanks!
|
|
|
|
|
Is this on the web page? If so, you can use:
System.Web.UI.Control.FindControl(string id)
If it's on a windows form, you'd probably have to do some funky iteration using GetNextControl or something...
Jeremy Kimball
|
|
|
|
|
Yes it's on a webpage. Thanks! I'll give this a try!
|
|
|
|
|
I am working with very limited screen space and I would like to add a toolbar that just has text but no images. If I leave the image list null, space is still set aside for the images.
Can I use the Toolbar control without images and without the control defaulting space for the image?
thanks
|
|
|
|
|
can't you just use a mainMenu bar? otherwise try altering the default width setting of the buttons - ButtonSize. hwo about turning off the AutoSize control? don't know if this is any help...
looking for hosting? ithium is good.
|
|
|
|
|
Hi every body!
please tell me, how can i get addresses from outlool express?
Thanks!
|
|
|
|
|
not sure but the address book file seems to be:
C:\Documents and Settings\[user]\Application Data\Microsoft\Address Book\[user].wab
don't know if this will help!
looking for hosting? ithium is good.
|
|
|
|
|
You can add a COM reference to the Outlook type library and interop it; not sure what's in there as far as an API goes. I haven't played with it for some time.
Jeremy Kimball
|
|
|
|
|
Hi, everyone
I have a dll file developed by someone else in VC6. Now I tried to use it in VS.Net, but how can I do that?
Thanks in advance.
|
|
|
|
|
If it is a COM dll, you can just use Add Reference meny by right click on your references in your project solution and select its dll in COM tab and simply use its namespace. If its not COM and its just like win32 dlls you can use DllImport to use its functions. See MSDN and this site for samples.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
It's not a com dll. Because when I am using "add reference", it doesn't work. Then I tried to use DllImport like this:
[System.Runtime.InteropServices.DllImport(@"C:\Visual Studio Projects\test\bin\Debug\dcli.dll", EntryPoint="AdminLogin")] <br />
public static extern bool AdminLogin(string lpctstrUser, string lpctstrPassWord);
Then I got a "DllNotFound" exception. But I already put the dll file in "C:\Visual Studio Projects\test\bin\Debug\dcli.dll". Do you know why?
Thanks in advance.
|
|
|
|
|
Ugh. I think I remember reading/hearing something about this. I'm not sure I remember exactly, but I don't believe you can explicitly provide a path as you have. I think it looks for "filename.dll" in a set order of pathnames.
Jeremy Kimball
|
|
|
|
|
Seems that your dll is delivering strings. If you want to get a string from a dll, you should use a string builder. Try something like this:
StringBuilder sb = new StringBuilder( 256 );
[DllImport( "myDll.dll" )]
public static extern void GetString( StringBuilder sb );
void myFunc()
{
GetString( sb );
Debug.WriteLine( "String = " + sb.ToString() );
}
|
|
|
|
|
hi,
how to redirect the output of certain window into my app to make this window appear in certain pos in my application consider that i have DirectX App
|
|
|
|
|
The short version is, you can't. Simply because you can't tell the app's paint code to repaint in another processes window. What you might want to try is grabbing the image of the original app window, sort of like Alt-PrintScreen does, and using the image in your app.
RageInTheMachine9532
|
|
|
|
|
Use multiple render targets. Remember a render target does not have to be a form object. PictureBox works well. Its been a while since I worked with DirectX9 but I can dig up some from work if need be.
|
|
|
|
|
Hi everyone,
Well i have a little problem. I have recieved some source code written in java that performs some xml parsing. I need to design a front end in C# and allow to call the java app. I'm currently doing that through a bat file which i call through System.Diagnostics.Process class. However, this "hangs" my c# program and i want the user to be able to see the output of a program in large text box (with scroll bars) within the form, in real time. Also, i have an animated gif that should continue to loop without being interupted. As soon as i execute process.start(), the program "hangs" while the java app runs in the background. The gif stops animating... the form looks funny with some control's dissapearing .. etc. What is the best way to do this?
Thanks.
I have read up on multi threaded applications on using them to update UI controls while processing in the backgroudn.. however the stuff was a little over my head.. any help would be appreciated.
|
|
|
|