|
Thanks ,leppie
Your code should work for ONE CONTROL, but the case here is not that:
I finally found out what is wrong with MyTab
As it wrappers the common controls TabControl when scrolling of the tab pages is needed
a new updown control is created that has nothing to do with the parent TabControl and thus it receives no messages through its parent
Now my question is do you have any idea of how to get to that updown control and prevent it from displaying?
Cheers,
Gogou
GAtanasov
|
|
|
|
|
You shouldn't really use addition or subtraction for bitwise operations. You can just use:
param.Style &= ~(int)(WindowStyles.VSCROLL | WindowStyles.HSCROLL);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hi!
I would like to know how to convert System.DateTime to System.Runtime.InteropServices.FILETIME?
Thanks!
|
|
|
|
|
long ftime = DateTime.Now.ToFileTime();
FILETIME ft = new FILETIME();
IntPtr pftime = Marshal.AllocHGlobal(Marshal.SizeOf(ftime));
Marshal.Write(ftime);
ft.dwHighDateTime = Marshal.ReadInt32(pftime);
ft.dwLowDateTime = Marshal.ReadInt32(pftime, Marshal.SizeOf(int));
Marshal.FreeHGlobal(pftime);
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
static FILETIME FileTimeFromDateTime(DateTime date)
{
long ftime = date.ToFileTime();
FILETIME ft = new FILETIME();
ft.dwHighDateTime = (int)(ftime >> 32);
ft.dwLowDateTime = (int)ftime;
return ft;
}
static DateTime DateTimeFromFileTime(FILETIME ft)
{
return DateTime.FromFileTime(
((long)ft.dwHighDateTime << 32)
+ (long)ft.dwLowDateTime);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
I'm trying to show XML that I get streamed to my app in a browser control. To test, I've dropped a control on a form and let the designer do the init work (BeginInit, misc. code, EndInit). Here's what I've added in my form's ctor :
<br />
object a = string.Empty;<br />
axWebBrowser1.Navigate( "about:blank", ref a, ref a, ref a, ref a );<br />
<br />
string xml = "<ROOT><test_node>42</test_node></ROOT>";<br />
((IHTMLDocument2)axWebBrowser1.Document).body.innerHTML = xml;<br />
The last line throws a NullReferenceException. I'm not sure why -- this code is supposed to work, right? Can someone pass on some advice on how to make this work or on the proper way to show XML in a browser control?
Thanks!
|
|
|
|
|
I believe several things are being confused here.
To get it short, Internet Explorer shows xml content when it loads a document with application/xml mime type, and applies a default (unless specified) xslt stylesheet, producing the nice rendering anyone can see.
You are quicker done by storing the stream to a local file, and call a Navigate2 to this local file.
Unless you do this, there is no association between your xml stream and what Internet Explorer shows : remember an html document is made of html tags (rendering semantics), not xml tags.
|
|
|
|
|
Is there a way to set the mime type on the IHTMLDocument2 object? I could have a ton of XML messages to display according to user selection -- having to save these as temp files or use one file as a temp writing space could be a pain. I could save some trouble if the mime type could be changed...is is possible?
|
|
|
|
|
I am aware of only two ways to associate a mime type to a document, in order to render the document in Internet Explorer :
- have a URI (local file, remote file) to play with, use Internet Explorer API to navigate to this URI
- have a web server generate the appropriate mimetype for you. In your case, the web server would simply redirect the stream, only adding the appropriate http header to it.
I am not aware of a successful way of changing the mimetype on-the-fly playing with the HTML Meta tag, of the form :
<META HTTP-EQUIV="Content-Type" CONTENT="text/html">
|
|
|
|
|
Yeah, playing around I see that the Type property is read-only. PutProperty on the AxWebBrowser doesn't seem to work either, but I can't find any docs on the valid data elements that can be passed to this method. Gotta love it when cool components like this go undocumented!
I think I'll just resort to your first suggestion : stream to a file then load that file in Navigate.
|
|
|
|
|
There some VB.NET (ouch) code (XMLViewer) on GotDotNet just posted last week doing what you want to do, it seems alot easier to work with VB.NET with these HTML interfaces.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
clickety[^]
He loads the Xml content from a file, transforms it using a default xslt, and then writes the output html in the web browser.
The sample itself is of no help, unless m_mond writes local files.
The good news is that the .NET System.Xml namespace both can load a xml file or a stream. This provides the required tool.
|
|
|
|
|
Draw image with alpha blending ? help, please
|
|
|
|
|
Hello,
I am writing a Windows Form program in C#.
It play some AVI's and I want to embed these
AVI's into a resource or something to deny
the user from accesing them.
How do I do that ?
thanks!
Orlanda
|
|
|
|
|
We have written a managed zip file component which we are deploying in a code elevate tool. We can create a file stream, write the zip file to disk, and it is ready to send to the receiving server. However, once the move is complete all we do is delete the file. It seems that it would be more valuable to just keep it all in memory and send the memory object to the receiving server.
The first go-around our file stream works great, fast, and gives us a zip file we can open.
Moving the stream to a MemoryStream, we get a larger file than what we had with our first test, and it is an invalid zip file which makes it real hard to determine what is going wrong.
Has anyone done a movement from file to memory with success and what can you suggest for a guidline to make this work.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
This is what have used with success:
<font size=2 face="Courier New"><font color="#FFFFFF"> </font><font color="#008040">
</font><font color="#000000">FileStream stream </font>= <font color="#000000">File</font>.<font color="#000000">OpenRead</font>(<font color="#000000">filename</font>);
<font color="#000000">byte</font>[] <font color="#000000">buffer </font>= <font color="#0000FF">new </font><font color="#000000">byte</font>[<font color="#000000">stream</font>.<font color="#000000">Length</font>];
<font color="#000000">stream</font>.<font color="#000000">Read</font>(<font color="#000000">buffer</font>, <font color="#FF0000">0</font>, (<font color="#0000FF">int</font>)<font color="#000000">stream</font>.<font color="#000000">Length</font>);
<font color="#000000">stream</font>.<font color="#000000">Close</font>();
<font color="#0000FF">#if(DEBUG)
</font><font color="#008040">
</font><font color="#000000">stream </font>= <font color="#000000">File</font>.<font color="#000000">OpenRead</font>(<font color="#000000">filename</font>.<font color="#000000">Replace</font>(<font color="#FF8000">".dll"</font>, <font color="#FF8000">".pdb"</font>));
<font color="#000000">byte</font>[] <font color="#000000">debugbuffer </font>= <font color="#0000FF">new </font><font color="#000000">byte</font>[<font color="#000000">stream</font>.<font color="#000000">Length</font>];
<font color="#000000">stream</font>.<font color="#000000">Read</font>(<font color="#000000">debugbuffer</font>, <font color="#FF0000">0</font>, (<font color="#0000FF">int</font>)<font color="#000000">stream</font>.<font color="#000000">Length</font>);
<font color="#000000">stream</font>.<font color="#000000">Close</font>();
<font color="#000000">Type</font>[] <font color="#000000">types </font>= <font color="#000000">Assembly</font>.<font color="#000000">Load</font>(<font color="#000000">buffer</font>, <font color="#000000">debugbuffer</font>).<font color="#000000">GetExportedTypes</font>();
<font color="#0000FF">#else
</font><font color="#000000">Type</font>[] <font color="#000000">types </font>= <font color="#000000">Assembly</font>.<font color="#000000">Load</font>(<font color="#000000">buffer</font>).<font color="#000000">GetExportedTypes</font>();
<font color="#0000FF">#endif
</font></font>
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
lippie -- looks like you may have got things reversed. We have working file steam logic we just cannot get the memory stream to work.
Here is what works:
<br />
public static int ZipFilesInto(string zipFileName,string dirPath,string searchPattern,bool recursive, DateTime dateFilter, string basePath)<br />
{<br />
ZipFile zf=new ZipFile(zipFileName,ZipFileOpenMode.Write);<br />
zf.BasePath=basePath;<br />
int ret=zf.Add(dirPath, searchPattern, recursive, dateFilter);<br />
zf.CloseZipFile();<br />
return ret;<br />
}<br />
We are trying to replace this with a memory stream. Here is what does not work.
<br />
public static byte[] ZipFilesToMemory(string dirPath,string searchPattern,bool recursive, DateTime dateFilter, string basePath)<br />
{<br />
MemoryStream m=new MemoryStream();<br />
ZipFile zf=new ZipFile(m,ZipFileOpenMode.Write);<br />
zf.BasePath=basePath;<br />
int ret=zf.Add(dirPath, searchPattern, recursive, dateFilter);<br />
byte[] buf = new byte[m.Length];<br />
int ost=0;<br />
int cnt=0;<br />
while(true)<br />
{<br />
cnt=m.Read(buf,ost,4096);<br />
if(cnt==0)break;<br />
ost+=cnt;<br />
}<br />
zf.CloseZipFile();<br />
return buf;<br />
}<br />
And....here are the methods being called:
<br />
public ZipFile(string zipFilePath,ZipFileOpenMode zom)<br />
{<br />
ZipFilePath=zipFilePath;<br />
OpenZipFile(zom);<br />
}<br />
public ZipFile(Stream baseStream,ZipFileOpenMode zom)<br />
{<br />
if(zom==ZipFileOpenMode.Write)<br />
{<br />
zos = new ZipOutputStream(baseStream);<br />
}<br />
else<br />
{<br />
zis = new ZipInputStream(baseStream);<br />
}<br />
}<br />
public enum ZipFileOpenMode<br />
{<br />
Read,<br />
Write<br />
}<br />
public bool OpenZipFile(ZipFileOpenMode zfom)<br />
{<br />
if(zfom == ZipFileOpenMode.Read)<br />
zis = new ZipInputStream(File.OpenRead(ZipFilePath));<br />
else<br />
zos = new ZipOutputStream(File.Create(ZipFilePath));<br />
<br />
return true;<br />
}<br />
public bool CloseZipFile()<br />
{<br />
if(zis!=null)zis.Close();<br />
if(zos!=null)zos.Close();<br />
zis=null;<br />
zos=null;<br />
return true;<br />
}<br />
It appears the developer is treating both the file stream writer and the memory stream writer as equals, which should be correct. In debug, the data in the memory stream is less than the total capacity allocated yet when he persists it to disk it saves the total capacity size.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
It seems the Zip library's Stream implementtaion is incorrect. What library are you using? I had problems with the one provided at SharpDevelop's site a few months back, and AFAI can remmeber, it was to do with streams.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Ahhhh -- we found the issue. The trouble is that the MemoryStream is not like most streams in that it does not have a reader and a writer. This makes it a bi-directional stream. As such it does not rewind itself for a read after a write. You must specify the position in the stream you want to read from or write to. So we created a read method and a write method to get it to work. Thus the final product is:
<br />
public static byte[] ZipFilesToMemory(string dirPath,string searchPattern,<br />
bool recursive, DateTime dateFilter, string basePath)<br />
{<br />
MemoryStream m=new MemoryStream();<br />
ZipFile zf=new ZipFile(m,ZipFileOpenMode.Write);<br />
zf.BasePath=basePath;<br />
int ret=zf.Add(dirPath, searchPattern, recursive, dateFilter);<br />
zf.ZipOutputStream.Finish();<br />
byte[] buf = new byte[m.Length];<br />
m.Position=0;<br />
m.Read(buf,0,(int)m.Length);<br />
zf.CloseZipFile();<br />
return buf;<br />
}<br />
<br />
public static int ExtractFromMemory(byte[] zipBuffer,string targetPath)<br />
{<br />
MemoryStream m=new MemoryStream();<br />
m.Write(zipBuffer,0,zipBuffer.Length);<br />
ZipFile zf=new ZipFile(m,ZipFileOpenMode.Read);<br />
int cnt=zf.Extract(targetPath);<br />
zf.CloseZipFile();<br />
return cnt;<br />
}<br />
BTW -- we are using the GNU Open Source Zip streams in .NET.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Good
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I have a buuton in my form,when I press this button,another form is open.How can I access controls in first form from second form?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
You can access controls in the first form if their modifiers value are set to public
No time to breathe
|
|
|
|
|
Really?!!!!!!!!!!!!!!!!!!!!!!!Thats my question.How?!!!!!!!!!I want to do it from second(child) one after it is shown.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
I'm sorry, my mistakes, I thought u wanna do it from the first form.
But I found a way that u can try, u can access the parent form's controls this way:
Form.ActiveForm.TopLevelControl.Controls[index]
No time to breathe
|
|
|
|
|
Thanks for your help but this return the control from second form,not parent form.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|