|
OK, thanks.
/\ |_ E X E GG
|
|
|
|
|
Hello! I'm a bit confused with an xml program i'm doing. The program goes through a xml-file wich is designed something like this:
<item>
<title> title </title>
<link>link</link>
<description>description</description>
</item>
<item>
... and so on
when it goes through the file i want it to make an instance of a class called Item everytime it finds the start of an item element, then fill the Item class fields (wich are title,link,description) and then put it in a Item array. But i can't get it to work at all.. Could someone give me some hint or anything?
Thanks!
|
|
|
|
|
Hmm, it seems like my xml-code got wiped! well, the root-elemtent(?) is Item, and then it has elements called title,link,description in it
|
|
|
|
|
Hi,
I'm overriding the ProcessDialogKey(Keys keyData) method of a textbox to handle keyboard input. Does anyone know how to convert the Keys values into characters? The usual letters and digits are no problem (A-Z, 1-9), because:
Keys.A = (int)'A' => (char)Keys.A = 'A'
But I can't handle some of the other keys. For example, if the user hits ";", the result of (char)keyData is some weird character ((char)192).
Is it possible to convert a Keys value to a character depending on the current user's keyboard layout? I don't want to use a large switch statement, because that doesn't consider different layouts (e.g. ";" = "ö" in German keyboard layout).
It has to be possible, because after all, the normal textbox just does that, doesn't it? I tried KeyConverters and some API-calls (toascii), but nothing seems to work right.
Any help would be highly appreciated, because I already spent hours on that (shame on me).
|
|
|
|
|
Interesting problem indeed. I also cannot find a solution. Perhaps try overriding protected virtual bool ProcessDialogChar(char charCode); instead? It gives you the char right away.
|
|
|
|
|
Thanks for the suggestion. But I don't think that I can use that method. What I want to do is a simple textbox control that shows the keys the user pressed, including the modifier keys (alt, ctrl, shift). The output should be something like 'Shift + Ctrl + F' or 'Alt + H' or 'Shift + ;'.
Even if I would use a combination of ProcessDialogKey and ProcessDialogChar, I would receive a ':' in ProcessDialogChar for a "real" 'Shift + ;', because ProcessDialogChar already takes the shift key into consideration. Besides that, some other keyboard layouts already need modifiers for some keys that aren't needed in other layouts (like ';' = 'Shift + ,' in German layout). So this will just result in the same problem I described first, but the other way round (how to get the Keys value for a certain character).
So if possible, I'd rather use ProcessDialogKey and convert the Keys to chars. Anyone?
P.S.: if someone knows how to distinguish the left and right shift/ctrl keys... the Keys-enum contains values for them, but the aren't used?
|
|
|
|
|
Here's a solution. Use the MapVirtualKey function located in user32.dll:
[DllImport("user32", EntryPoint = "MapVirtualKey")]
public static extern int MapVirtualKey(int wCode, int wMapType);
It converts scan codes, virtual keys and characters. From the Win32 api help:
Parameters
==========
uCode
[in] Specifies the virtual-key code or scan code for a key. How this value is interpreted depends on the value of the uMapType parameter.
uMapType
[in] Specifies the translation to perform. The value of this parameter depends on the value of the uCode parameter.
0
uCode is a virtual-key code and is translated into a scan code. If it is a virtual-key code that does not distinguish between left- and right-hand keys, the left-hand scan code is returned. If there is no translation, the function returns 0.
1
uCode is a scan code and is translated into a virtual-key code that does not distinguish between left- and right-hand keys. If there is no translation, the function returns 0.
2
uCode is a virtual-key code and is translated into an unshifted character value in the low-order word of the return value. Dead keys (diacritics) are indicated by setting the top bit of the return value. If there is no translation, the function returns 0.
3
Windows NT/2000/XP: uCode is a scan code and is translated into a virtual-key code that distinguishes between left- and right-hand keys. If there is no translation, the function returns 0.
Return Value
============
The return value is either a scan code, a virtual-key code, or a character value, depending on the value of uCode and uMapType. If there is no translation, the return value is zero.
************
This will do a Keys value to character conversion:
(char)MapVirtualKey((int)keyData, 2)
Regards,
kalme
|
|
|
|
|
Before I even start, I apologize for asking a NON-C# question in here. I've posted questions in nearly every forum in this site, and the responses in this one are by far the best. On that note, here is my question:
We have a situation at work where we've encountered a problem with accessing files which are located on another machine as the IIS server. We're using the File System Object to access these remote files. The problem is that the FileExists function always returns false for a file on another machine. This is a permissions issue, and I have some workarounds for it. Setting up a user account on the remote machine for the IUSR_COMPNAME account isn't really feasible, since this needs to be in commercial software, and the password for this account is generated dynamically. Yes, we could hack the registry and get this, but it's something we're trying to avoid. We could also have the ASP page start an external application to access the file, but again, we have the overhead of starting and ending a separate application, as well as the fact that we have to set up some way of giving this application the names of the actual files to access. I guess my question is, is there a method of doing this which actually works? If I search the web, I see that this issue has come up a lot...and the only real work-around I've seen is putting the IUSR account on the remote machine. Is there another way, and if so, what are the steps, or where can I find a quality article on this topic?
Again, while this isn't a pure C# question, it's still an issue that somebody using C# might face, so it's worth sharing. Thanks everybody.
|
|
|
|
|
I think if you are trying to do this with the ASP code you need to explicitely map the logical path to a physical one before trying the FileExists() function. Search on these lines.
|
|
|
|
|
No, it doesn't work by mapping to a virtual directory either. I wouldn't have posted this question if it were that easy...thank you though for the suggestion.
|
|
|
|
|
Hello,
Is there any property for numeric updown control in C# to make the text part of it to be invisible like we had in VB6.
Thanks,
thatsqlguy
|
|
|
|
|
Hi Buddy:
I am going to serialize object in my xml schema.
for this purpose I get public fields and property
and then serialize this to xml.
but in many cases this serialization raise Stackoverflow exeption
please help me...
|
|
|
|
|
hi,
Show the serialisation bolck of your code.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
string tempstr = "";
XmlDocument xml = new XmlDocument();
XmlDocument tempxml = new XmlDocument();
//m_value is object for serialize
Type objecttype = m_value.GetType();
PropertyInfo[] objectproperty = objecttype.GetProperties();
XmlNode node = xml.CreateNodeXmlNodeType.Element, "DataObject", "");
xml.AppendChild(node);
xml["DataObject"].SetAttribute("type", "object");
for(int i = 0; i < objectproperty.Length; i++)
{
object tempobj = new object();
PropertyInfo pi = objectproperty[i];
if(pi.Name != "Item")
{
tempobj = pi.GetValue(m_value,null);
}
//S is static method from DS class for serialize object that switch type of DataObject and then call S method recursively.
tempstr = DS.S(tempobj);
tempstr = "<" + objectproperty[i].Name + ">" + tempstr + "";
tempxml.LoadXml(tempstr);
xml["DataObject"].AppendChild(xml.ImportNode(tempxml.FirstChild, true));
}
return xml.InnerXml;
|
|
|
|
|
Hi buddy:
I going to write a method that read an custom serialized object(in xml format) and then
create object's field dynamically from this xml and then instantiate bject from this
type and then set values of this object.I can't find good article for this purpose.
thank u for your help.
|
|
|
|
|
hi,
Which sort of article you want.
serialisation ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Are linking Console Windows..the same as linking WindowApp Forms?
If not please send some code how to..i don't have a book to look it up, nor freedom of online looking up.
-thanks
George
|
|
|
|
|
Hello,
I've tried filling a tree view with a large database on a worker thread (so my main window keeps responding.)
I get an InvalidOperationException saying that I'm doing it from the wrong thread. If I do it from the main thread, it is very slow, and can take up to 30 seconds.
Any ideas? Thanks,
-- LuisR
___________
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
|
|
|
|
|
DISCLAIMER: I've never tried this so I don't know if it will work.
Would you be able to generate the tree structure first and then when your data loading thread is finished it fires an event to tell the main thread it is finished. The event handler then takes the nodes and attaches them to the tree control.
This would mean that for 30 seconds you have an empty tree control - but at least the application is responsive.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Mmm interesting idea... I'll give it a try! thanks!
During thos 30 seconds, I could fill the tree with a "Populating tree control, please wait..." node.
-- LuisR
___________
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
|
|
|
|
|
If you want to modify a control from a thread other than the thread that created it, you should use the Invoke method of the Control (in that case the TreeView) to invoke the function that adds the node to the tree. A simple example for adding a node which takes a string parameter for the node could be:
private void AddNode(string nodeText)<br />
{<br />
myTreeView.Nodes.Add(nodeText);<br />
}
then you can declare a delegate to call this function:
private delegate void AddNodeDelegate(string nodeText);
and then from any thread, you can safely do this:
string nodeText = "This is my safe node text";<br />
AddNodeDelegate myAdd = new AddNodeDelegate(AddNode);<br />
myTreeView.Invoke(myAdd, new object[] { nodeText } );
|
|
|
|
|
I'm making plans to build an application that will be a MDI Host application that loads plugins from a department web server. Does anyone have any examples or advice thaqt they could give on this project?
Thanks
Moebious
|
|
|
|
|
|
Hey all,
Work is really boring so I'm going to write a screen scraper. But the best say to do this is using Regex's, something I need to work on because it's a particular area of weakness. If a page has the following structure:
<html>
<head>
<title>foo</title>
</head>
<body>
<table><tr><td>foo</td></tr></table>
<table><tr><td>foo</td></tr></table>
</body>
</html>
Is there a regex I could use to pick up what's between the tags? Like a regex to grab the title, another for the first table, and the second?
Thanks much
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
Sure, here is a quick example so I am sure you can expand on it:
private void ShowContent(string s)
{
Regex r = new Regex("<td>*[a-z]*</td>", RegexOptions.IgnoreCase);
Match m = r.Match(s);
while(m.Success)
{
string val = m.Value.Delete(0, 4).Delete(m.Value.Length - 4, 4);
if(val != null)
Console.WriteLine(v);
m = m.NextMatch();
}
}
- Nick Parker My Blog | My Articles
|
|
|
|