|
It could be a bit harder than I thought...
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi All,
I need to iterate through a range of IP Address. What I have are a start and end IPAddress objects. How can I get the at the address in between these, we'll say add them to an ArrayList?
I have tried incrementing the long integer IPAddress.Address but this doesn't work as the address 10.20.30.40 is not 1 less than 10.20.30.41!!
Any ideas?
Thanks,
dp
|
|
|
|
|
IPAddress ip = IPAddress.Parse("192.168.0.1");
IPAddress ip2 = new IPAddress(
IPAddress.NetworkToHostOrder(
IPAddress.HostToNetworkOrder((int) ip.Address) + 1)
);
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi,
I want to put an image to a simple button. I put an image to my button but page refreshes itself when I click. The button was created to open a popup window but it refreshes itself(main window) and this bothers me.
I need some opinions to solve this problem,I'm sure someone did a lot of buttons like this.The code will be running on the net, so that shorter codes will be better
Kind Regards,
-
kromozom@msn.com for MSN Messenger
-
|
|
|
|
|
JavaScript or set the target. I can never remember which one, either _self or _blank.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi guys,
I was just wondering if this is only with me, or maybe somebody else out there experienced the same thing. When I put a button on my web form and connect a code to the click event of it (I use C#, but it shouldn't be language specific), then in the InitializeComponent() I got the code, something like:
this.btnSomething.Click += new System.EventHandler(this.btnSomething_Click);
and that is fine. Now after a while and after adding some more events and controls and deleteing some controls, it happens sometimes that the some lines gets deleted, and there will be no response to a click event!? The button is there, but it does not respond for it can not find its procedure. I suppose as I add controls on the form, this portion of code gets rewritten, but it is not supposed to lose any lines.
This is something similiar to binding controls to member variables in C++ 6 when programming database applications, when sometimes the wizard rewrites the code of DDX routines and tumbles up the order of member variables to controls.
If anybody of you have experienced the same, I would like to hear you experiences.
Thank you.
.
|
|
|
|
|
There is a bug in VS.NET where if you cut and paste controls the chosen event handlers get lost. I'm not positive, but it might happen if you copy/paste as well.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
The best way in VS .NET to add events to WinForm components is to either double click on the object in design view or on the property pane click events (the little lighning bolt) and pick what kind of event you want. Then VS will automaticly generate the code for that event. So you only have to code the functionality for the event. Any code added to the generated methods will be deleted or changed automaticly. So the best way is to make your own method or use VS to add it. Hope this helps.
JProd
|
|
|
|
|
Hello again.
Now I tried the Save and Load routines from the DUMeter project !
They're very good .. and I only gave my FileName and my TreeView-Control as
Object and the saving of the file works fine.
And it looks like the samples in the help.....
But now as I want to load that file again to fill my TreeView
I have a nice Exception :
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
I have no idea what causes the error. The file isn't in use and was not edited.
He stops at the command where he starts reading the file :
System.Xml.XmlTextReader reader = new XmlTextReader(filename);<br />
<br />
while (reader.Read()) <-- HERE<br />
{ ....
Could someone please again help me in this case ?
|
|
|
|
|
j-hannemann wrote:
Now I tried the Save and Load routines from the DUMeter project !
They're very good ..
Thanks, but that will only work for flat classes. It was never intended to walk a tree. Here's some code that mite help, but I have not made a FromXml function.
public class HashTree: System.Collections.DictionaryBase
{
char del;
public HashTree()
{
del = (char) 0;
}
public HashTree(char delimter)
{
del = delimter;
}
internal int level = 0;
private HashTree(int level, char del):this(del)
{
this.level = level;
}
public virtual HashTree this[string key]
{
get
{
string[] tokens = key.Split(del);
HashTree outer = this;
foreach (string keyt in tokens)
{
if (!outer.Dictionary.Contains(keyt))
outer.Dictionary.Add(keyt, new HashTree(outer.level + 1, del));
outer = outer.Dictionary[keyt] as HashTree;
}
return outer;
}
}
public virtual System.Collections.ICollection Keys
{
get
{
return this.Dictionary.Keys;
}
}
public virtual System.Collections.ICollection Values
{
get
{
return this.Dictionary.Values;
}
}
private object obj;
public object Value
{
get {return obj;}
set {obj = value;}
}
public string ToXml()
{
StringBuilder output = new StringBuilder();
string pad = "";
for (int i = 0; i < level; i++)
pad += "\t";
foreach (string key in Keys)
output.AppendFormat("{2}<{0}>\n{1}{2}</{0}>\n",
key, (this[key].Count > 0 ? this[key].ToXml() : (pad + "\t" + this[key].Value + "\n")), pad);
return output.ToString();
}
} And the usage is easy.
HashTree tree = new HashTree('.');
foreach(....)
{
tree
["rootlevel"]
["nextlevel"]
["anotherlevel"]
.Value = "somevalue";
tree["rootlevel.nextlevel.anotherlevel"].Value = "somevalue";
}
string xml = tree.ToXml(); This give you a nice tree, but I havent got around to making a load from XML method. If you can make one, I'll give you credit .
Cheers
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 again
Thanks leppie for you code but I am not that good to write
a load routine for it.
This is my first c# project.
I've done saving now with another more simple solution.
But it works fine.
But I just wanted to try a little with XmlTextReader/Writer --
and again everytime I want to read the file I got an exception.
Saving works perfect ... and the file looks fine...
Has somebody any idea what I can do ??
|
|
|
|
|
Hi
I have a problem with an unmanaged callback. First the C API.
BOOL CALLBACK YourRecordProc(
void *buffer,
DWORD length,
DWORD user
);
...
DWORD CALLBACK MyRecordingWriter(void *buf, DWORD len, DWORD user) {
fwrite(buf,1,len,file);
return TRUE; In C# I define:
public unsafe delegate int UnsafeRecordCallBack(void* pbuffer, int length, int user); And the callback function:
private unsafe int UnsafeProgress(void* buffer, int length, int user)
{
Trace.WriteLine(++COUNT, "caLLBACK count");
return 1;
} Now I debug this with native debugging set as well and this happens:
caLLBACK count: 1
caLLBACK count: 2
caLLBACK count: 3
caLLBACK count: 4
caLLBACK count: 5
caLLBACK count: 6
First-chance exception at 0x001b67b6 in RecordTest.exe: 0xC0000096: Privileged instruction.
Unhandled exception at 0x001b67b6 in RecordTest.exe: 0xC0000096: Privileged instruction.
Like WTF Eisha. Any suggestions? What Win32 Thread of the 2 zillion is the culprit? How can I trace what is happening here? It appears to crash quicker if I move my mouse.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Looks like thread collision. Add a critical section[^], just in case.
|
|
|
|
|
Thanx. Although thats NOT the solution, is that not just the same as Monitor or using the lock command?
Anyways, it works without problems (with "empty method") when passing a static delegate instance. Could it be that .NET is moving function addresses around?
[edit]static as in the delegate itself is static, not just the method[/edit]
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
leppie wrote:
Although thats NOT the solution, is that not just the same as Monitor or using the lock command?
Yes. Your callback being C code, I thought of suggesting WIN32 CriticalSections.
leppie wrote:
Could it be that .NET is moving function addresses around?
From watching sscli code, the only "good" reason for addresses to be rebased on-the-fly would be appdomain switch, but that sounds odd enough.
|
|
|
|
|
.S.Rod. wrote:
From watching sscli code, the only "good" reason for addresses to be rebased on-the-fly would be appdomain switch, but that sounds odd enough.
Too odd But thanks for the info.
I have made and implemetation of the callback and it works flawlessly in a "static" context. O well, I can just internally do that and pass it onto an instance delegate and let consumers of the assembly register that delegate. Maybe an event perhaps...
Cheers
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Here is some info I got from the author:
"Yep, callbacks need to be static member functions. There is no "this" pointer in static functions though, so you should pass "this" as the user parameter in the BASS_RecordStart call. This applies to C++ anyway, but I guess C# too?"
Now it appears that C++ callbacks can be instance delegates, but C callbacks has to be static. Any idea how I could pass this as an int into the start method or will marshalling do its own thing?
Cheers
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
leppie wrote:
Now it appears that C++ callbacks can be instance delegates, but C callbacks has to be static. Any idea how I could pass this as an int into the start method or will marshalling do its own thing?
"this" is on the call stack. (the meaning of all ldarg.0 code ops before each function call).
|
|
|
|
|
.S.Rod. wrote:
"this" is on the call stack. (the meaning of all ldarg.0 code ops before each function call).
English? Is it possible to convert an object to an int? Or do I need to reference something else, like a handle so I can recreate the object in the static function?
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 tried to compile the following pattern to match the filename from a complete file path:
(?!.*\\\\).*
Example:
"C:\My Programs\Office\Word.exe" - match result : "Word.exe"
This works fine when I create an instance of System.Text.RegularExpressions.Regex.
However, in the compiled form the pattern above would always result in:
"C:\My Programs\Office\Word.exe"
Does anybody know what the reason is? Or do you have a better pattern to use?
Thanks!
|
|
|
|
|
Try this one:
.*\\([^\\]*)
Don't forget to duplicate the \ if in C#.
You'll have two matches, the second one is the file name.
It is a bit slower, because it has to do some backtracking, but may work in your case.
I see dumb people
|
|
|
|
|
Thanks for the tip Dan,
I tried the pattern and here's the result:
--------------------
.*\\([^\\]*)
C:\My Documents\foo.doc
Matching: C:\My Documents\foo.doc
0 => C:\My Documents\foo.doc
1 => foo.doc
--------------------
Is there an option I could set so that the first match gives me the intended result right away?
thanks again
|
|
|
|
|
Investigate the Path class for this, instead of using regular expressions. There's a method in there made for what you are trying to do.
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
If the file name is in the middle of a text, the System.IO classes won't help him, e.g., for highlighting paths and URLS on e-mails.
I see dumb people
|
|
|
|
|
I've got a treeview/listview pair in a backup program that acts similar to windows explorer, enumerating all drives,folders and files on a PC. I've set it up so there are checkboxes for entries in both controls, so you can select entire folders or just individual files...
I'm wanting to save all the checked items to a "job" file so the backup component can read the job file and perform the backup according to the selections.
Do I have to build this information dynamically (using an array or collection), or do the treeview/lisview controls keep this info around for me?
thanks.
|
|
|
|