|
Does anybody knows where to get code for a flicker-free and ownerdraw Treeview?
Thanks
Stefan
|
|
|
|
|
is there anyway i can turn a string (whithout knowing what the string will be)into a exception of that string (for exsample x is System.Exception) how can i perform this case ? any ideas? or would i have to involve something like a foreach statement and i would need to parse though all of the classes within the namespace to compare it to a string.... i have no clue... all help would be much appreciated.
Jesse M
|
|
|
|
|
What are your trying to do exactly? What are comparing to what?
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
well with this program i have all the exceptions that are caught pass to a class with a few atributes being required Expsample...
void Exception(Exception ex,string Title,bool Require close)l
well from the (Exception ex) i can derive the cause of the error into a string. from that string i can run a switch to show the correct error message(by pointing it to the class that deals with the exception).
the string for exsample will say System.NullRefrence exception. I then tell my error(form) to get its data from Say Exception.Message; ect. which works fine. I created my (costom) exceptions class Inheriting from System.Application ,Error, The problem is i couldnt change the Error.Message Property because it was read only. So when i try to get the message property to my costom Form it comes up as null. Basicly what im trying to say is if i can customize this property (Exception.Message, ect) it would solve the problem i have.
here the code i have that i use to inherite from.
<br />
public class BadEncryptionDataException: ApplicationException<br />
{<br />
public BadEncryptionDataException() : base()<br />
{<br />
this.HelpLink="Mailto:Res1s5yd@verizon.net";<br />
}<br />
public BadEncryptionDataException(string message) : base(message)<br />
{<br />
}<br />
public BadEncryptionDataException(string message,Exception inner) :base(message,inner)<br />
{<br />
}<br />
//i clipped the end of it...cause it was to long...but thats the just of it.
Jesse M. How can i costomize the Message property ?
The Code Project Is Your Friend...
|
|
|
|
|
public class BadEncryptionDataException: ApplicationException
{
public BadEncryptionDataException() : this("No message"){}
public BadEncryptionDataException(string message) : this(null){}
public BadEncryptionDataException(string message,Exception inner) :base (message,inner)
{
this.HelpLink="Mailto:Res1s5yd@verizon.net";
}
} Just an OOPsie LOL
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
thats all there is to it then huh ?
The Code Project Is Your Friend...
|
|
|
|
|
jtmtv18 wrote:
thats all there is to it then huh ?
If it does it for yoiu I guess...;P
But have a look what I did in nBASS:
public BASSException() : this(GetErrorCode()){}
internal BASSException(int code) : base(GetErrorDescription((Error)code))
{
err = (Error) code;
} Where GetErrorCode() and GetErrorDescription() is static functions in my Exception class.
To throw an exception, I check for errorstate. Then all I need to do is throw new BASSException() . The Message get inserted automatically. DOnt be afraid to ask more questions.
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 few questions indeed actually... i like your method alot better. How did you set it up to add the message in automaticly ? also what are the functions behind the propertys your wrote in your class. How can i get the error code also ? thanks for awnsering my questions by the way. im instrested in setting up a clean and effient error system you know ?
Jesse M...(did i stay up to late? its 1:57 am)
The Code Project Is Your Friend...
|
|
|
|
|
OI what happened to rest of the message
Like said thsoe 2 functions are static and internal to my exception class. Now if you design it nicely, you can have something like this:
public class MyException {
internal enum ErrorCode
{
None,
User,
Programmer,
Unknown,
}
static ErrorCode errorcode = ErrorCode.None;
internal static ErrorCode Error
{
get {
return errorcode;
}
set {errorcode = value;}
}
internal static string GetErrorDescription(ErrorCode code)
{
switch(code)
{
case ErrorCode.User:
return "User error occured, check blah blah for dohdoh";
case ErrorCode.Programmer:
return "Programmer error occured, email blah";
case ErrorCode.Unknown:
return "Unknown error occured, no help available";
case default:
return "No error";
}
}
public MyException():this(Error){}
internal MyException(ErrorCode code):base(GetErrorDescription(code))
{
errorcode = ErrorCode.None;
}
} In you calling code:
...
if (somestring == "badstring")
{
MyException.Error = Error.User;
throw new MyException();
}
... Hope this helps
PS: maybe another helper function:
static void CheckString(string str)
{
if (somestring == "badstring")
{
MyException.Error = Error.User;
throw new MyException();
}
}
...
CheckString("badstring");
...
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 see said the blind man to his deff dog.....i shall make it work...thanks leppie.. !! i think our time zones / sleep parterns are in perfect sync wouldnt you say ? lol
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
jtmtv18 wrote:
think our time zones / sleep parterns are in perfect sync wouldnt you say ? lol
No, I just woke up, you are going to sleep.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
damn leppie that hole thing really really works great... thanks so much.. i would of NEVER in a million years been able to figure that out !! thanks Alot. it works like a charm ill barely have to change anything in my program to make it work...thanks a hole hell of alot...Can you point me to some articles and such that taught you these things ?
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
jtmtv18 wrote:
Can you point me to some articles and such that taught you these things ?
Trial and Error (without Source Control), all my C# and programming knowledge is self taught, hence bad coding conventions I use.
jtmtv18 wrote:
it works like a charm ill barely have to change anything in my program to make it work...thanks a hole hell of alot
You mean that code I pasted? I just wrote that in the textbox, wasnt even sure if it would compile, but I'm glad it did
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 had to change a little to get it to work...but i could clearly see how it worked you know? sometimes for me the best way to learn is to "follow" the code i call it lol....when i first started programing..it was greek...now odly enough i can follow it...and know what its going to do in a perticular place.....bottle necks........anyways thanks leppie.
jesse m
The Code Project Is Your Friend...
|
|
|
|
|
Hi all,
since days I'm looking for a solution to get the information stored in the <xsd:appinfo> or <xsd:documentation> tag from a known XmlElement (for example got by a XPath selection)... Could anybody give me a hint how I can access to this values in C#?
Here the C# sample code, a small XML sample and the related XML Schema:
XmlTextReader tr = new XmlTextReader(sXMLFile);
vr = new XmlValidatingReader(tr);
vr.ValidationType = ValidationType.Schema;
XmlTextReader sr = new XmlTextReader(sSchemaFile);
XmlSchema schema = XmlSchema.Read(sr, new ValidationEventHandler(ValidationHandler));
sr.Close();
vr.Schemas.Add(schema);
vr.ValidationEventHandler += new ValidationEventHandle(ValidationHandler);
doc = new XmlDocument();
doc.Load(vr);
vr.Close();
string selectExpr = "//test:TestData/test:Collection/test:Element";
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("test", "http://xsd.mytest.com/test.xsd");
XmlNode root = doc.DocumentElement;
XmlNode myElementNode = root.SelectSingleNode(selectExpr, nsmgr);
------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<test:TestData xmlns:test="http://xsd.mytest.com/test.xsd" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<test:Collection>
<test:Element Id="1">11.00</test:Element>
</test:Collection>
</test:TestData>
------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema targetNamespace="http://xsd.mytest.com/test.xsd" xmlns:test="http://xsd.mytest.com/test.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
<xsd:element name="TestData" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Collection">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>This is the documentation of the Collection</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Element" default="1.00">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>This is the documentation of the Element</xsd:documentation>
<xsd:appinfo>
<formula>5.000000 + 3.000000</formula>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="test:ElementType">
<xsd:attribute name="Id" type="xsd:int" default="1" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="ElementType">
<xsd:restriction base="xsd:double">
<xsd:minInclusive value="0.100000" />
<xsd:maxInclusive value="10.000000" />
<xsd:pattern value="\d{1,2}.\d{1,6}" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
------------------------------
The validation works fine and I really get the error notification, that the value of "Element" is out of range. I also get a valid myElementNode object back. But how can I read the Documentation/AppInfo out of this myElementNode? Is it impossible or am I just too stupid? Do I need to write my own parser for that?
Thanks for your help!
Mirco John
|
|
|
|
|
I'd like to make a Winform shows a printer list available using comboBox..
However.. I don't know How to get a Printer List....
Is there anyone?? Help me..
|
|
|
|
|
If you don't want to bother with C-based printer enumeration callbacks (which happen to work differently depending on the operating system), I would suggest this fast hack :
- read this registry key : HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Control \ Print \ Printers
- the default printer is listed in : HKEY_CURRENT_USER \ Software \ Microsoft \ WindowsNT \ CurrentVersion \ Windows \ Device = "..." (on NT systems). And it's located in the [Device] section of the win.ini file (on 9X systems).
.NET provides API to access the registry and profile strings :
- Microsoft.Win32.Registry
- also check out Cp articles
|
|
|
|
|
Thanks..
I made it..
I appreciate your kindness...
However I found another way..
System.Drawing.Printing.PrinterSettings.InstalledPrinters
It shows currently installed printers.. Not using Registry..
|
|
|
|
|
bania wrote:
System.Drawing.Printing.PrinterSettings.InstalledPrinters
Ooo, nice to know
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hello,
I have few questions,
1. How to know whether scrollbars appeared in a list control at run time or not.
2. How to restrict user changing listview columns widths.
3. How to know whether a user has changed list view columns or not. How to keep track of changed list view columns.
4. How to know the names of all tcp and serial ports in a computer.
Chito
|
|
|
|
|
chito wrote:
1. How to know whether scrollbars appeared in a list control at run time or not.
You could figure out on your own how many items can appear in your list before the scroll bars apear and then in your App test if the amount of items has gone past the number you found. Of course this would only work if the listbox stayed the same size.
"We will thrive in the new environment, leaping across space and time, everywhere and nowhere, like air or radiation, redundant, self-replicating, and always evolving." -unspecified individual
|
|
|
|
|
1. .VScroll returns true of false
2. and 3. : also you are probably not going to like it, the only way I can think of is to override the WndProc method and provide a handler for the WM_NOTIFY message (HDN_TRACK notification). Lookup MSDN for more info about this WIN32 header control notification.
|
|
|
|
|
How would I go about encoding from a memory buffer to an mp3 file using the lame dll? Just want to feed the dll pcm data on the fly.
|
|
|
|
|
When I create a class library in C# it creates a DLL. The DLL it creates also references another DLL.
Is it possible to put the DLL I'm referencing INSIDE the DLL I created so I do not have to redistribute the referenced DLL ?
|
|
|
|
|
Only if you have the sources for the extra DLL or if said DLL is really a .NET Module (An Assembly without an Assembly Manifest) which isn't the case because you've been able to reference it. Anyway, what you could do is ILDASM the referenced DLL and ILASM the source file you get into a .NET Module, then use AL.exe to link the two.
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|