|
I've extended the TreeNode control to add an additional property. Now, what
I'd like to do is capture the MouseDown event so I can perform some tasks
when either the left or right mouse button is clicked. However, I can see
that the TreeNode doesn't have any events to override. I tried capturing it
with the TreeView control, but can't get the underlying object that was
clicked.
Any ideas? I was thinking about creating my own custom event in my extended
control (TreeNodeExID)... but I can't find any examples or documentation...
-AC
Andrew Connell
IM on MSN
andrew@aconnell.com
|
|
|
|
|
Override the WndProc procedure and handle the Windows Message WM_LBUTTONDOWN:
class TreeNodeExID : TreeNode
{
...
public const int WM_LBUTTONDOWN = 0x0201;
protected override void WndProc(ref Message m)
{
if(m.Msg == WM_LBUTTONDOWN)
{
}
base.WndProc(ref m);
}
}
|
|
|
|
|
RSA Parameters has an Exponent value and Modulus value how do i combine these to get the public key
|
|
|
|
|
How can I fill ( or create ) a Enum using DB records as items ??
Or How can I override a enum declaration ?
( I want to add items to an Enum declarated in other class )
thanks
Marcelo Duarte
uruguay
|
|
|
|
|
This may be possible by progmatically writing code and then using Emit() to generate a runtime assembly, and then using that code.
But really, you shouldnt add so much complication. Better to keep the records in their native format.
|
|
|
|
|
Christopher Lord wrote:
Better to keep the records in their native format.
Agreed.
It might also be an option to check out Typed Datasets.
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
Hi!
I want to know if there's an API I can use in .NET that makes it possible to read text from any program if I e.g. do a right-click and hold ALT.
Something like an OCR API reading from screen... well, I don't know how to describe it correctly, but if you know the tool "Babylon Translator" you know what I mean...
Thanks in advance!
|
|
|
|
|
I have set up a remoting host and client, and they work well. Now I would like the host to send a file to the client, but can't figure out how to do it. I need a function in the remoted object that would look something like this-
Public Function FileTran() as File
return C:\test.txt
End Function
I know this is completely incorrect, but you get the idea of what I'm trying to do.
Can anyone please give me some pointers?
Thanks in advance,
Steve
P.S. VB.NET code prefered, but C# would be fine too.
|
|
|
|
|
Well, look into Stream objects. I've never used them over a remoting link, but if MS did a really good job it should be seemless.
If not, you'll have to chunk and send, which will be slow but will get the job done.
Simply chunk your file into a buffer, and send the buffer across the wire as an array of bytes, and then reconsitute. Thats not gonna be a whole lot of fun, though.
|
|
|
|
|
Do you think it would matter whether I marshal by ref or serialize? I'm asking because I've never remoted serialized objects, but I've seen them mentioned frequently.
|
|
|
|
|
I've only done minimal work over remoting as well. I figure that serializing a remote object will work great, but again I cant be sure. sorry.
|
|
|
|
|
I've been messing around with streams and had all kinds of problems, so I decided to try putting the file into an array of bytes like you said (thanks for that advice). I'm just wondering if you know what the disadvantage of that is.
|
|
|
|
|
Large files will be very inefficent, since the whole thing will have to be read into ram, and then 'sent' all at once. Since the wire cant send the data all at once, this will cause a 'lock up' unless you use async or threading.
|
|
|
|
|
I have tried both methods, returning a file stream vs. filling a big byte[] buffer and I found that the byte[] buffer was much faster which suprised me. I too was worried about the inefficiency of using large chunks of ram but I guess it just depends on the amount of RAM on your server, the average file size and the number of requests served. You could also compress the file data before you put it in the byte[] buffer, saving memory and speeding transfer times.
Joel
|
|
|
|
|
When you used the buffer method, did you use a singlecall or singleton object? Cause I'm using a singlecall object, and everytime I call the function to send the next buffer, the stream object (that is global in the remoted object) has been erased. On top of that, I can't find a method to have the filestream start at byte X without going back through the file again. Any advice or code snipets you could offer?
Thanks for the info,
Steve
|
|
|
|
|
I'm not sure I understand how you are doing the transfer. Basically I tried two methods.
The file stream approach works like this. You will have a remote method like GetFile() which returns a file stream object. The client calls GetFile(). The server creates a new file stream object by opening the desired file on the server machine. The server returns this file stream object to the client. The client is then free to call the Read() on the file stream object and when done Close(). Using this method it does not matter what kind of remote object (Singleton etc.) But this method seems to be kind of slow even when you minimize the number of read calls by making your read buffer large.
The other method I use is to have a remote method GetFile() that returns a byte[]. The client calls GetFile() and the server opens the desired file reads the entire file into the byte[] and returns this to the client. The client is then able to write the entire byte[] to it's local disk. This seems to work very well for me (tested up to 13MB file).
Hope this helps - Joel
|
|
|
|
|
That makes sense. I was trying to send only 4k at a time, so I was having all sorts of problems with getting the server to send the next 4k rather than the first 4k. But I realize that I'm never actually going to be sending a file too big to fit into a byte array. I'll just send it in one big array like you did.
Thanks for the help,
Steve
|
|
|
|
|
Been using C# for a while now, but just never had to interact with a database (actually a running joke in the office... only dealt with web services, XML, sockets, and file IO). Anyway, I'm having a bit of a problem finding a solution to my challenge (two of them).
Quick Overview:
My application uses Access as a database (desktop app). On demand, I pull data from the Access database into a Dataset, using it as a working copy of the database. At anytime the user can save/reject his changes.
Challenge 1:
I am populating a combobox with values from one of my datatables. The value being added to the control is the "name" (not unique) of the record, but I have a unique ID for each record (int). When the user selects an option in the combobox, I want to be able to get the ID of the record the user selected. Currently, as I add items to the combobox, I add the ID's to an array where the combobox.selectedindex = index of the array. Makes it tough when they add a value to the combobox (I have to add it to the datatable, then flush and update the array and combobox so everything is synch'd. There MUST be a better way This is my work around... just wanted to get it working and then go back and do it the right way.
Challenge 2:
Once my data is in the dataset, I need to be able to query it. The "datatable.contains" method helps, but what do I do when I need to find a specific record? I was looking for something that would do the following: DataRows theRecords = datatable.filter("intRecID=1"); However, I can't find a ".filter" or compareable item.
Any ideas on how to overcome these two challenges? Just about run all leads & ideas down...
Andrew Connell
IM on MSN
andrew@aconnell.com
|
|
|
|
|
Challenge 1: This is pretty easy to do. Say you have a DataSet with a DataTable named "Table 1" in "Table 1" you have Columns "id" and "name". You want "name" to be what the users see and "id" to be returned.
comboBox1.DataSource = DataSet1.Tables["Table 1"];
comboBox1.DisplayMember = "name";
comboBox1.ValueMember = "id";
Then to get the associated id from the user's selection (I'm assuming ID is an AutoIncrimenting Integer)
id = (int)comboBox1.Value;
Challenge 2: You're close, very close. DataTable does not impliment a filter but DataView Does. And you can easily get a DataView from a DataTable by using the DefaultView Property thus:
DataSet1.Tables["Table 1"].DefaultView.RowFilter = "intRecID=1";
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataViewClassRowFilterTopic.asp?frame=true for more info.
|
|
|
|
|
Fantastic! you hit the nail on the head. Only thing I had to change from your code above was the .Value property doesn't exist so I replaced it with .SelectedValue .
Thanks Chris!
-AC
Andrew Connell
IM on MSN
andrew@aconnell.com
|
|
|
|
|
Oops, got me there. Even in the .NET framework they can't keep these properties too consistent
|
|
|
|
|
I just started studying the .NET Remoting Architecture.
In the samples, you import or reference several system namespaces:
// C#
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
The last line gives a compile error saying the Tcp namespace does not exist.
The doc for the TcpChannels class says it exists within this namespace.
The intellisense will not show it either.
Is there something that I need to install or enable to be able to see this class?
Just wondering...
|
|
|
|
|
Solution was to add System.Runtime.Remoting.dll as a project reference - Duh.
|
|
|
|
|
I am trying to use the Internet Explorer control in my C# project. I imported the control into the toolbar and dropped it onto my form. This, of coarse, imported SHDocVw.dll.
Now, I can navigate around with the control just fine, but I wanted to do something a bit more tricky. I have HTML resources embedded in my project and I want to display them using the DOM in the IE control. So, next, I went searching for the Document property. To my surprise, it was typed as Object. After a bit more research, I realized that the DOM was in a separate dll. MSHTML.DLL to be exact. I imported this only to find another problem.
VS.Net imported the all of the interfaces and classes. The one of interest is the HTMLDocumentClass class, which implements the IHTMLDocument2 interface. This interface has the writeln that I want to use. The problem is that VS.Net imported the method as:
writeln(params object[] psarray)
But the original C++ version is actually
HRESULT writeln(SAFEARRAY* psarray)
and the documentation states that psarray is actually a BSTR[]. When I try to pass a string or string[], the framework doesn't catch that it needs to convert it and Explorer just throws an exception.
Since this is method isn't imported using DllImport or anything, how can I make VS import this method to take a string instead?
Jared Bienz
jbienz@hotmail.com
|
|
|
|
|
Hey there everyone, does anyone happen to know where I can find the ASCII code for the left, right, up, down arrows and the spacebar?
|
|
|
|