|
Hi,
I have a problem with changing the opacity property of my main form. I want to open a form from my context menue, and want to change the transparency of my main form in this form. I've attached my current source code for the "helper" form below, when I execute this code I get a NullReferenceException. I have tried to figur the problem out for a good while now, but I can't find the problem. Does anybody of you have an idea what the problem could be?! Thank you very much!!!
<br />
private void setButton_Click(object sender, System.EventArgs e)<br />
{<br />
double val = (double)this.numericUpDown1.Value;<br />
val = val/100;<br />
this.ParentForm.Opacity = val;<br />
this.Close();<br />
}<br />
|
|
|
|
|
sommarafton says: I get a NullReferenceException.
This is obviously a reference problem! You have to pass the parent form to the "helper" form yourself.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi,i would like to know how to extract data from a web page.As example,i want to get the items in a table from a html page and then add them into list control.
Thanks for any kindly help
|
|
|
|
|
First you have to get the webpage content. Try using System.Net.HttpWebRequest . Once you have the content you can use something like SgmlReader[^] to access you table and then populate the list control.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
//VC++ :
PackData(CString strInput)
{
CString strReturned;
char nLength = strInput.GetLength() + 2;
char b= 0x03;
char zero = 0x00;
strReturned.Format("%c%c", nLength, b);
strReturned += strInput;
for(int i = 0;i<(32 - nLength); i++)
strReturned += zero;
return strReturned;
}
what does the identical c# code look like?
Thanks!
|
|
|
|
|
Should go something like this. You might want to look at System.Text.StringBuilder instead of using a string for strReturned, as each modification to a string creates a new string, whereas StringBuilder modifies the string directly.
public string PackData(string strInput)
{
string strReturned;
char nLength = (char) (strInput.Length + 2);
char b = (char)0x03;
char zero = (char)0x00;
strReturned = string.Format("{0}{1}{2}", nLength, b, strInput);
for(int i = 0; i < (32 - nLenght); i++)
{
strReturned += zero;
}
return strReturned;
}
And take it with a grain of salt, I didn't try to compile this.
Any remotely useful information on my blog will be removed immediately.
Judah Himango
|
|
|
|
|
Hi!Himango,
But you know that string in VC++ is ASNI standard,but UNIC standard in C#.
And char type in VC++ has 8 bits,but 16 bits in C#.So what about this?
Thanks!
|
|
|
|
|
You might want to look at the System.Text.Encoding class.
Any remotely useful information on my blog will be removed immediately.
Judah Himango
|
|
|
|
|
|
I just want to find out how you would do this in code. If I had a table that was scripted to a file, what would I use from C# to execute this?
|
|
|
|
|
The Query Analyzer is the easiest way.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi all,
Would it be possible to install software (MSI) from within a Windows Service written in c# which is running as LocalSystem?
What we're looking for is a concept such as used by anti-vurus applications.
Thanks,
Peter
|
|
|
|
|
Yes. Read the Windows Installer SDK on http://msdn.microsoft.com/library[^]. Specifically, you can P/Invoke MsiInstallProduct given a path to the MSI package, along with the command-line specifying the property settings (if any).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I am trying to extend ADODB Classes in C# & then override their methods.
I added reference to ADO 2.7 and then extended the classes (connection, recordset, ....). After that i started overriding the methods of ADODB base class.
Then i tried to make a type library (.tlb) of the same using regasm utility, so that I can access the extended classess from existing asps.
Over here it's giving me error as follows:
RegAsm error: Types extending from COM objects should override all methods of an interface implemented by the base COM
class.
I did override all 8 methods Connection class (BeginTrans, Cancel,Close, CommitTrans, Execute, Open, OpenSchema, RollbackTrans ).
Do we need to override the events as well? Could anyone please explain what exactly i am doing wrong?
Thanks & Regards,
Mohit
Sample code:
using System;
using ADODB;
using System.Data.SqlClient;
namespace ADOLibrary
{
///
/// Summary description for Class1.
///
///
public class Connection : ConnectionClass
{
override public System.Int32 BeginTrans()
{
return base.BeginTrans();
}
override public void Cancel()
{
base.Cancel();
}
override public void Close()
{
base.Close();
}
override public void CommitTrans()
{
base.CommitTrans();
}
override public ADODB.Recordset Execute(System.String CommandText ,out System.Object RecordsAffected , System.Int32 Options)
{
return base.Execute(CommandText,out RecordsAffected,Options);
}
override public void Open(System.String ConnectionString ,System.String UserID ,System.String Password ,System.Int32 Options)
{
base.Open(ConnectionString,UserID,Password,Options);
}
override public ADODB.Recordset OpenSchema(ADODB.SchemaEnum Schema ,System.Object Restrictions ,System.Object SchemaID)
{
return base.OpenSchema(Schema, Restrictions, SchemaID);
}
override public void RollbackTrans()
{
base.RollbackTrans();
}
}
|
|
|
|
|
A continuing saga ...
My C# application follows several links in a web site, finally arriving at a link to a pdf file. I issue an httpget for this file and receive a response like the following:
HTTP Response 200 (OK) "APPLICATION/PDF" (72'407 bytes)
But what is returned from the streamRead.ReadToEnd is just an html page that says the pdf is downloading and that this page will be updated every seven seconds until the download is complete. How do I navigate my way around this so that I end up with the pdf document?
|
|
|
|
|
Do you actually need a stream to the PDF, or do you just want to download it? If you just want to download it, you can try this:
WebClient Client = new WebClient ();
Client.DownloadFile("http://url_to_file.com/file.pdf" , @"C:\TEMP\file.pdf");
If this doesn't work, then you may need to check the HTML page you do get to see if there is actually a redirect to the PDF file.
Best Regards,
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I need to extract data from the pdf file. So ideally I would just read it in, parse it and extract the data and discard it. We're talking about up to several hundred pdf files per day, so storing the pdf doesn't make much sense when the target data is to be aggregated into a database.
|
|
|
|
|
I hope you're not using the StreamReader to download the PDF. It's a binary stream, so you should use the Stream returned by the HttpWebResponse.GetResponseStream as is. A StreamReader is a derivative of TextReader and is, naturally, for text.
The PDF would have to come down on a separate stream. HTML itself does not support multipart-mime like email (though there is a rather nice, proprietary MHTML developed by Microsoft for use with IE for the last couple of major versions, and in the new Office 2003 system). What the relationship between the HTML page you're reading and the PDF is, I don't know. You'd have to explore the packets coming off the wire, as well as the HTML source. Perhaps this is in a frame or something? Even using a chunked download (downloading a range of bytes) this wouldn't work with interleaved HTML.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
A method returns a unsigned char***
how do I Marshal this to some managed data?
This is mabye something....
I receive a IntPtr from the method and would think I should use the PtrToStructure, but not sure
I have there managed classes
[StructLayout(LayoutKind.Sequential)]
public class A
{
public byte[,] data;
}
[StructLayout(LayoutKind.Sequential)]
public class B
{
A data;
}
Anybody have an idea?
|
|
|
|
|
To compile assemblies at the runtime I need full path to Managed DirectX assemblies, but not in GAC. The problem is that "AssemblyFoldes" registry entry isnt on Windows 98, on 2000 and XP there is.
Could you help me ?
Wizard_01
|
|
|
|
|
You need to have the SDK installed. The DirectX runtime contains GAC-only assemblies. You can actually reference those, but you need to know the physical path (and those paths - for each file - can be very long).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
When I Create a C# project and run it without doing any thing i have an error message "an exception System.Aritmetic exception Occured...."
Please help me to solve this problem i have istalled windows XP SP2 and visual studio.Net 2003 several times to solve the problem but it works for some time and then again this error occurs.
I am tired of installing them again and again.
Please.......
|
|
|
|
|
Can you catch the exception and post the StackTrace? Add a try-catch block in your main() function and write code in the catch block to dump the entire StackTrace in a log file.
Salil Khedkar [^]
|
|
|
|
|
What is required to run an application on a machine which does not have .NET installed in it?
|
|
|
|
|
The dot net frame work should be the basis. You also have to copy your dlls for you project. If its a com object you also need to register the dll.
You will get some errors if you are missing any other dll's from the windows/system32 dirrectory.
|
|
|
|