|
Hi,
I've done CRC code before (but never this one), and I know from experience
it takes some doing to get it right.
may I suggest you first try with a one-character string, doing this may make
it possible to compare and understand the difference between what you get
and what you expect.
|
|
|
|
|
Hello everyone,
I would like to be able to get the position of the mouse once the user click the mouse.
Can someone be kind enough to tell me how this can be done?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Try using Form's MouseClick method ,
private void GetPosition(object sender, MouseEventArgs e)
{
int x = e.X;
int y = e.Y;
MessageBox.Show(x.ToString()+","+y.ToString());
}
|
|
|
|
|
Hello KKun,
Thanx for the help, mate. I did exactly what you suggested and it is almost working! What I mean by almost is that I only get the mouse location at one particular Panel in the Windows Applicatin rather than the entire Appliication's Window.
Can you think of anything which can cause such a problem?
Thank you for your help, mate/
Khoramdin
|
|
|
|
|
For your problem ,i estmate that you have written code under Panel's MouseClick method ,i mean that not entire Application's Click method ,try again and make a reference to the the following code fragment,Good Luck!
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
protected override void OnMouseClick(MouseEventArgs e)<br />
{<br />
int x = e.X;<br />
int y = e.Y;<br />
MessageBox.Show(x.ToString()+","+y.ToString());<br />
base.OnMouseClick(e);<br />
}<br />
|
|
|
|
|
I have a XML document (not of my making) which starts like that:
==========
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
........................
==========
I read it with code such as:
Stream s = .....
using(XmlTextReader xtr = new XmlTextReader(s))
{
xtr.MoveToContent(); // <<== problem here
xr.Read();
.....
}
The problem that I have is, if the user's computer is not connected to a network, the xtr.MoveToContent() fail with the following exception:
=========
Stack :
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset
(String systemId, String publicId)
at
System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter
.PushExternalSubset(String systemId, String publicId)
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.ParseInDocumentDtd(Boolean
saveInternalSubset)
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlReader.MoveToContent()
-------- Caused by Exception --------
Exception : System.Net.WebException
Message : Unable to connect to the remote server
Source : System
Help :
Stack :
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri,
ICredentials credentials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String
role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenStream(Uri uri)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset
(String systemId, String publicId)
-------- Caused by Exception --------
Exception : System.Net.Sockets.SocketException
Message : A socket operation was attempted to an unreachable host
Source : System
Help :
Stack :
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
=========
But I absolutely don't care about the DTD, in fact there is nothing at this URL.
I try many various settings, but I can't see a way to get around this problem other than a try/catch.
The problem is: it is easy to forget to put try/catch around the first XML read.
Is there any better way?
|
|
|
|
|
sorry for the double posting guys.
|
|
|
|
|
Hello!
I am trying to read an XML file that specifies an external DTD source, namely http://www.apple.com/DTDs/PropertyList-1.0.dtd
When I execute the reader.MoveToContent() in the code below
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
settings.ProhibitDtd = false;
using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(uri, settings))
{
reader.MoveToContent();
customers sometimes get this exception:
Exception : System.Xml.XmlException
Message : An error has occurred while opening external DTD 'http://
www.apple.com/DTDs/PropertyList-1.0.dtd': Unable to connect to the remote server
Source : System.Xml
Help :
OSVersion : Microsoft Windows NT 5.1.2600 Service Pack 2
Thread :
Stack :
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
...
Exception : System.Net.Sockets.SocketException
Message : A socket operation was attempted to an unreachable host
Weird is that the customers have internet access because the XmlReader is created from an uri... but the DTD seem to be not available.
Can I somehow deactivate the DTD processing completely?
Any hints would be greatly appreciated.
TIA
Pakl
|
|
|
|
|
is it possible to get a local copy of the dtd and validate against that? It may be that some transient error is causing you a problem.
Russ
|
|
|
|
|
From MS newsgroup:
==
XmlReader always checks if DTD exists (to make sure document is
wellformed), it doesn't actually parse it. So the solution is to provide
to XmlReader custom XmlResolver, which will return something dummy when
requested to resolve "http://www.apple.com/DTDs/PropertyList-1.0.dtd".
==
|
|
|
|
|
Hey fellas..
Need a lil help..
I am starting up with a application of cryptography and steganography. But i am lil confused like which language to use. I have option to do it in C++(borland), C++.NET OR C#.NET. Not VC++...
All depends in which language would i get more reference over the net and more help.
Can C#.NET perform all the tasks that C++ can. I want to know it now so that i dont end up in a mess. As in stego i want to use carriers like .mp3, .jpeg, .pdf etc. So would that be fine with C#.NET.
Any suggestions are welcome...
Thanks a lot
|
|
|
|
|
If you ask in a C# forum the answer will not be Cobol...
|
|
|
|
|
hehehe wt a joke.
if ill ask this in C++ forum they ll say the same. But i am asking from them who works on both C#.NET AND C++.
|
|
|
|
|
i think its better to use VC++
My small attempt...
|
|
|
|
|
I am trying to add a combo box to my C# which gets its possible values from a lookups table, but is bound to a value in a different table. I can’t quite figure out how to do this. I have two binding sources defined – one for the lookups table and one for the table which stores the value. I tried setting DataSource/DisplayMember to get the values from the lookups table and then tried to set DataBindings to the value in the other table. I tried binding Text, SelectedItem and SelectedValue, all with no luck.
This seems like it should be something easy to do, but I just can’t seem to find any examples online.
Any help would be greatly appreciated. Thanks.
|
|
|
|
|
I dont know if this will work but you could try to build up a datatable from the diferenct datasources and bind the combo box to the datatable.
|
|
|
|
|
I don't know how to do this, and I searched Google/MSDN for it also but none helped -- may be I typed in the wrong search keywords !
Anyways, what's the base type of a generic class?
E.g.
Assume I've a List<Employee>:List<T> and List<Company>:List<T> , how do I get "List" as the inner base type of List<Employee> and List<Company> ?
If I do GetType() on my _listEmployees , I get System.Collections.Generic.List`1[[Employee]] . And the base type of this type (e.g. _listEmployees.GetType().BaseType ), it is System.Object .
I'd like to use "is" keyword on my generic objects to compare them.
One more question on the "generic" declarations.
In my app, I've an abstract class called GenericValueExpression<T> and concrete classes NumericValueExpression , TextValueExpression , DateValueExpression which derive from GenericValueExpression<int> , GenericValueExpression<string> , and GenericValueExpression<DateTime> respectively.
How can I declare a collection of GenericValueExpressions?
E.g. List< GenericValueExpression<???> > _myValueExpressions ? What would go instead of ????.
Thanks for your help.
- Malhar
|
|
|
|
|
Any generic/templated class system is essentially a class factory. Without a type, the class doesn't really exist, and each type means a new class is created. The beauty of .NET is that it's created in memory, for C++, it would be created in your exe.
I'd suggest the easiest way to do your collection, is to define an interface for the common functionality, and then create a collection of that type. But, I'm not sure if that would work, if the methods take or return T, as they invariably would.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sorry for the delayed reply. But IMO this really seems like a missing functionality in language. Simple things such as not being able to have a collection of Nullable types makes me wonder if this was intentional or something they overlooked. e.g. List<Nullable> myNullableValuesCollection = new List<Nullable>();
Here's my real requirement:
I have the following classes/interfaces:
- IDomainObject<br />
- DomainObject : IDomainObject<br />
- Employee : DomainObject<br />
- Company : DomainObject<br />
- Project : DomainObject
I've the following UI elements:
- IDataboundView <T> where T:IDomainObject<br />
- BaseView : UserControl<br />
- EmployeeManagementView : BaseView, IDataboundView<Employee><br />
- CompanyManagementView : BaseView, IDataboundView<Company><br />
- ProjectManagementView : BaseView, IDataboundView<Project>
In the BaseView's load method, I'd like to be able to do something like ...
void OnLoad(..)
{
if (this is IDataboundView)
{
Get the generic type parameter for the IDataboudView (e.g. Employee, Company, Project...)
Get the list of IDomainObjects (e.g. EmployeeColl/CompanyColl/ProjectColl etc)
Call the IDataboundView's method for "this" instance and set the collection
}
}
But I cannot achieve the above. Do you have any suggestions?
|
|
|
|
|
What you can do is have an instance of T as a member variable, and use 'is' on that.
C++ templates were certainly more powerful, but, realistically, most people used them in the ways that generics are now used.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi All,
I am working on a MCMS page with a dropdown list of all the existing posting Name. The page will render a "preview" of the page depend on the dropdown value. Could someone tell me how to work this out? Thanks in advance
gsdg
|
|
|
|
|
Good People,
I need to cast from my class to a native data type. For example: int payRate = MyNumberObject. How do I do that? Also, how do I build my class such that it can be interchangeable with the native numeric types.
Any information or a link to some information would be great.
Thanks,
BP
|
|
|
|
|
BlitzPackage wrote: I need to cast from my class to a native data type.
And ?
BlitzPackage wrote: int payRate = MyNumberObject
int payRate = MyNumberObject as int;
od
int payrate = (int)MyNumberObject;
Inherit your class from that type.
BlitzPackage wrote: interchangeable with the native numeric types.
|
|
|
|
|
LongHC wrote: int payRate = MyNumberObject as int;
You can't as a value type.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sorry, my fault, thanks for correcting me.
|
|
|
|